Comparing Pathfinding Algorithms
Give every algorithm the same start, goal, walls, and terrain, then watch the routes emerge side by side. Draw on the shared board and press Compare, or use Next and the slider to inspect the recorded events. Algorithms join the comparison as their pages launch.
Start with Costly shortcut. BFS optimizes the number of moves, DFS follows a branch without an optimality guarantee, and Dijkstra and A* optimize the total cost. Ordinary cells cost one to enter, terrain marked 5 costs five, and the starting cell costs zero. Movement is in four directions, with no diagonals.
The useful numbers are visited cells, moves, and cost. One animation tick advances one recorded event for each algorithm, so finishing first is not a measurement of CPU time. A* can visit fewer cells than Dijkstra, but the heuristic and the board determine how much it helps. On boards with equal movement costs, BFS also finds a cheapest route.