~/lab/pathfind — zsh
cd ..thomas@parkin ~/lab $ ./pathfind# A*, Dijkstra, BFS & friends race through a maze
expanded 0path –
man path

Drag on the grid to draw walls or mud (mud costs 5 to cross). Drag S andG to move them. Then hit search.

A* expands nodes in order of f = g + h: cost so far plus a Manhattan-distance guess of the cost remaining. That guess never overestimates, so A* still finds the cheapest path while exploring far less thanDijkstra (which is A* with h = 0). Greedy uses only h: fast but easily fooled. BFS is optimal only when every step costs the same, so watch it walk straight through mud.DFS is here for comic relief.

Mazes come from a randomised recursive backtracker, with a few extra walls removed so there are loops.