Experimental

Maze Generator and Solver

Generate mazes with recursive backtracking, Prim, Kruskal or Wilson, solve them with breadth-first search, and see how each algorithm leaves a recognisable signature in the result.

Last reviewed by the Radiatus Cloud team

Statistics appear here.

Need this done properly for your business?

Radiatus delivers secure cloud, DevOps & compliance engineering.

Book a free consult

Every generation algorithm leaves a visible signature

All of these produce a perfect maze, meaning exactly one path between any two cells and no loops, and they produce visibly different ones. Recursive backtracking carves long winding corridors with few junctions, because it always goes as deep as it can before turning back. Prim's algorithm grows outward from a seed and produces short branches and many dead ends. Kruskal's joins random pairs and looks uniformly textured. Wilson's is the only one here that samples uniformly from all possible mazes, so it looks like nothing in particular, which is exactly the point.

Bias is the interesting property, not a defect

Recursive backtracking cannot produce a maze with many short branches, because its rule forbids it. That makes it fast and it makes the output a small corner of the space of all perfect mazes. Wilson's algorithm removes the bias entirely using loop-erased random walks, at the cost of being much slower to start. Which matters depends on whether you want a maze that looks good or a maze drawn fairly from the whole space, and those are genuinely different requirements.

The solution length says more than the size

A large maze with a short solution is easy regardless of its dimensions. The useful measures are how long the solution path is relative to the grid, how many dead ends the maze has, and how many junctions sit on the solution: that last number is roughly how many decisions a solver actually faces. A maze with a hundred dead ends and four junctions on the path is much easier than the count of dead ends suggests.

Related tools

Frequently Asked Questions

What is a perfect maze?

One with exactly one path between any two cells and no loops. All four algorithms here produce perfect mazes, and they produce visibly different ones.

Why do the algorithms look different?

Because each has a bias. Recursive backtracking makes long corridors, Prim makes short branches with many dead ends, Kruskal looks uniform, and Wilson has no bias at all.

Which algorithm is best?

It depends what you want. Recursive backtracking makes mazes that feel good to solve; Wilson draws uniformly from every possible maze, which is what you want if the maze is a sample rather than a puzzle.

How is the maze solved?

Breadth-first search, which finds the shortest path and, in a perfect maze, the only one. The number of cells it visits shows how much of the maze had to be explored to find it.

What makes a maze hard?

Junctions on the solution path, more than size or dead-end count. Each junction is a real decision; a dead end far from the path is never encountered.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Choose an algorithm and generate a maze.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.