🗺️ Pathfinding Algorithm Visualizer

Draw walls and watch four search algorithms hunt for the goal: DFS wanders, BFS floods evenly, Dijkstra matches BFS on a uniform grid, and A* heads straight for the target. The visited cells and the final path show you exactly why.

Draw: drag = wall · click S/E to move
Draw walls, then pick an algorithm and press Find path.
What you're seeing

BFS explores in rings — guaranteed shortest path on unweighted grids. DFS plunges down one corridor as far as it can — fast but its path is usually not the shortest. Dijkstra visits cells in order of total cost — on a uniform grid it looks exactly like BFS because every step costs the same (it's the generalisation that handles weighted edges). A* adds a "distance to goal" heuristic, so it steers straight toward the target and visits far fewer cells.