Skip to content

🏰 Maze Generator

Watch a maze being carved in real time, then solve it with pathfinding.

Start End

Pick an algorithm and press Generate to watch the maze being carved, then Solve to find the shortest path.

How it works

DFS Backtracking starts from a cell, randomly visits an unvisited neighbor (removing the wall between them), and backtracks when stuck. This creates long, winding corridors with a bias toward fewer dead ends.

Prim's algorithm grows the maze outward from a random frontier, producing mazes with shorter dead ends and more branching — a different feel from DFS.

The solver uses Breadth-First Search (BFS), which always finds the shortest path. Blue cells show every cell BFS explored; the yellow path is the optimal route from start to end.