Inspiration

I decided to visualize the A-Star algorithm because I wanted to gain a deeper understanding of how it works. I wanted to see the algorithm in action and observe each step, which would help me to understand how it finds the shortest path. Additionally, I thought that visualizing the algorithm would make it easier to identify and debug any problems that arise, and help me improve its performance. Furthermore, I was interested in exploring new ideas and ways of thinking about the problem, and I thought that visualizing the algorithm might inspire me to come up with creative solutions. Overall, visualizing the A-Star algorithm will be a valuable tool for learning, teaching, debugging, improving performance, and inspiring creativity.

What it does

A-Star visualization shows the process of the algorithm finding the shortest path between two points. As the algorithm runs, I can see the path being generated and the nodes being explored. I can also see how each node's cost is considered, as the algorithm balances cost and efficiency. The visualization highlights the decisions that the algorithm makes, which helps me understand the logic behind the pathfinding process. Additionally, I can see how the cost of each node is updated as the algorithm continues to explore the graph. Also, I can add obstacles or difficult-to-traverse paths. Overall, my A-Star visualization provides a clear and intuitive representation of the algorithm's behaviour and helps me understand how it finds the shortest path.

How I built it

The A* algorithm is a search algorithm that is used to find the shortest path from one point to another. The algorithm uses a combination of two concepts: a heuristic function that evaluates the estimated cost from one node to the goal node, and a priority queue that allows the algorithm to select the node with the lowest cost to explore next.

In each step of the algorithm, the node with the lowest f score (where f score is the sum of the g score (the cost from the start node to the current node) and the h score (the heuristic estimate of the cost from the current node to the goal node)) is selected and its neighbors are explored. The cost of each neighbor is updated, and if the neighbor has not been visited before, it is added to the priority queue. This process continues until the goal node is reached, or there are no more nodes in the priority queue to explore.

The A* algorithm is guaranteed to find the optimal solution if the heuristic function used is admissible (never overestimates the cost) and consistent (the cost from one node to any of its neighbors is less than or equal to the sum of the costs of moving from that node to its neighbor and from the neighbor to any other node). In practice, A* is often implemented using the Manhattan distance or Euclidean distance as the heuristic function, as these functions are both admissible and consistent for the grid-based search problems that A* is commonly used for.

Challenges we ran into

The implementation of the barrier was the most difficult. The idea is to create two types of barrier, one which is traversable but the path cost is high and the other is not traversable. The click implementation was difficult.

Accomplishments that I'm proud of

I have been able to successfully implement a visualization project without much prior knowledge.

What I learned

Learned more about the tips and tricks for optimizing and improving the search algorithm

What's next for Visualizing A-Star Algorithm

  1. I would like to optimize it even further.
  2. Improve the UI and UX.
  3. Create a more generic implementation, so that it would work across different platforms.
  4. Implement it in a robot for path finding
Share this project:

Updates