Maze Generator & Solver

Recursive Backtracker Maze Generation with A* Pathfinding Visualization

Ready to generate a maze. Click "Generate New Maze" to begin.
Start Position
End Position
Shortest Path
Visited Cells
Walls
0
Path Length
0
Cells Visited
0
Time (ms)
25×25
Maze Size

How It Works

Recursive Backtracker (DFS) Maze Generation: This algorithm creates a perfect maze (no loops, one unique path between any two cells) by starting at a random cell, carving passages while keeping track of visited cells, and backtracking when no unvisited neighbors are available.

A* Pathfinding: An informed search algorithm that finds the shortest path from start to goal. It uses a heuristic (Manhattan distance) to prioritize exploring promising cells, making it more efficient than algorithms like Dijkstra's for grid-based pathfinding.

Breadth-First Search (BFS): Explores all neighbors at the present depth before moving on to nodes at the next depth level. Guarantees the shortest path in unweighted grids but explores more cells than A*.

Use the controls above to generate a new maze, solve it with different algorithms, and adjust visualization settings.