A* Pathfinding Algorithm

Click cells to add or remove walls, then run A* to see explored cells and the final shortest path.

Ready.

Start Goal Explored Path Wall

How A* works

A* combines the cost already travelled, g(n), with a heuristic estimate to the goal, h(n). Here the heuristic is Manhattan distance, which is appropriate because movement is limited to up, down, left, and right.