← All Tools

🧭 A* Pathfinding Visualizer

Watch A*, Dijkstra, BFS, and Greedy Best-First search the same grid β€” one cell per step. Paint walls, sprinkle in weighted terrain (mud costs more), pick a heuristic (Manhattan / Chebyshev / Euclidean / Octile), then race all four to see which explores fewer cells and which finds a truly optimal path.

Grid

Wall Erase Start Goal Mud (w=2) Sand (w=5) Swamp (w=9)
open set (frontier) closed set (visited) final path

Stats

Cells expanded
0
Open set size
0
Path length
β€”
Path cost
β€”

Race all four

Click Race all four above to run every algorithm on the current grid without animation and compare expansions vs path cost.

A* is optimal iff the heuristic is admissible (never over-estimates true remaining cost). Manhattan is admissible for 4-way; Octile for 8-way; Euclidean is always admissible. Greedy skips g-cost entirely β€” fast but can return a much longer path.

The algorithms in one sentence each

BFS β€” expands cells in FIFO order, so the first time it reaches the goal is guaranteed to be a fewest-hops path (ignores terrain weights).

Dijkstra β€” expands the unvisited cell with lowest g (cost from start). Optimal for any non-negative weights. Same as A* with h = 0.

Greedy Best-First β€” expands the cell with lowest h (heuristic to goal). Fast, but ignores accumulated cost, so its path can be arbitrarily bad.

A* β€” expands the cell with lowest f = g + h. If h is admissible, the returned path is optimal; if additionally consistent, no cell needs to be re-opened.