← Playground

Pathfinding

royhp.com

A search algorithm explores the grid outward from the start, expanding one cell at a time. The bright frontier is the set of cells waiting to be explored; behind it the explored region is tinted by visit order. BFS and Dijkstra always return a shortest path; A* does too with an admissible heuristic, but reaches the goal far faster; Greedy is fastest of all yet can miss the shortest route. Draw obstacles, drop in weighted terrain, then drag the markers and watch the path re-solve live.

Draw walls or weights, then press Visualize
Cells visited
0
expanded by the search
Path length
steps start → goal
Path cost
weighted distance
Algorithm
A*
optimal w/ admissible h
Algorithm
Heuristic
Maze

Click and drag on the grid to draw walls; drag over a wall to erase. Switch the brush to drop weighted terrain (each weighted cell costs ×12 to enter) — then compare BFS (ignores weight, shortest in steps) with Dijkstra and A* (cheapest in cost, routing around the mud). Drag the start or goal after a run and the path re-solves instantly. Works with touch. Shortcuts: Space visualize, C clear walls, P clear path, D diagonal, M maze. Steady-state rule of thumb: A* explores ≪ Dijkstra ≈ BFS.