A* Pathfinding Simulator
Compare g, h and f at every expansion to see why A* beats plain Dijkstra on a grid.
A* with Manhattan h. f = g + h, so it prefers cells that look closest to the goal.
step 1 of 82
expandingopen setclosedfinal pathcell numbers are f — click any cell to add or remove a wall
A* Search
- Cells expanded
- 0
- Open set size
- 1
- Path length
- —
searching…
Why the heuristic matters
Both find the same shortest path, because Manhattan distance never overestimates on a 4-connected grid. The difference is effort: run both and compare “cells expanded”. Dijkstra spreads out in every direction; A* leans towards the goal.
← → to step, or use the buttons above.