A* algorithm visualization
A visual representation of the A-star algorithm was my summer project. I was very interested in pathfinding algorithms especially this one as it is often used in computer science and could be also used in games.
Download and play with it yourself!It was made in C++ and 2D Framework. Below are some code snippets showing how I calculate G, H and F costs as well as the algorithm’s main function.
- “G cost” is a movement from starting point to a given square on a grid.
- “H cost” is the estimated movement from starting square to the final square.
- “F cost” is a sum of these two.


Check out the demo below
In this program user can paint a wall/map which is represented with dark grey squares. The green square is the start and red is the finish and they can also be set up by the user. When the algorithm runs it creates yellow and purple squares. They represent squares that have been already evaluated (purple) and squares which have not been evaluated yet (yellow). Once the calculation is done the shortest path is shown in blue colored squares.