Maze Generator

Pick an algorithm and watch it carve. The eight here produce mazes that look and feel completely different, and the numbers underneath say how — dead ends, solution length, how straight the corridors run.

0 / 0
32
20
0%
120/s

The same seed and the same size always produce the same maze, so you can compare algorithms on equal terms. SVG export gives clean vector walls — the format you want for a plotter or a laser cutter.

Dead ends—
Solution length—
Longest path—
Mean straight run—
AlgorithmDead endsSolutionLongest pathStraight runCharacter

How the eight differ

All of them produce a perfect maze: every cell reachable, exactly one route between any two cells, no loops. Every one is a spanning tree of the grid. What differs is which spanning tree, and the character that gives the result. These numbers are for the current size and seed, so they update as you change them — press the row to load that algorithm.

Why the dead-end count is the number that matters

A maze that is 30% dead ends feels completely different from one that is 10% dead ends. The recursive backtracker carves as far as it can before backing up, so it produces long snaking corridors and relatively few junctions — it is the one that feels like a proper labyrinth, and it is what most games use. Randomized Prim grows outward from a single point like frost, which produces many short stubs and a maze that feels busy but shallow. Both are correct; neither is better in the abstract.

Uniform is a specific thing, and only two of these are it

Wilson’s algorithm and Aldous–Broder both sample uniformly from all spanning trees of the grid — every possible perfect maze equally likely. Nothing else here does. The backtracker is heavily biased toward long corridors, binary tree towards one diagonal, sidewinder towards horizontal runs. If you need a maze with no algorithmic fingerprint — for a study, a puzzle set, a benchmark — those two are the only correct choices, and Wilson is the one to use because Aldous–Broder spends most of its time wandering over cells it has already visited.

The two fast ones give themselves away

Load Binary tree and look at the top row and the right column: both are a single uninterrupted corridor, every time, on every maze it will ever produce. That is not a bug — the algorithm makes one independent decision per cell, carving either north or east, so the cells on the top edge can only go east and the ones on the right edge can only go north. It runs in one pass with no memory at all, which is why it exists, and the diagonal texture is the price. Sidewinder is the same idea done one row at a time; it fixes the right column but the top row is still a single corridor.

Braiding

Turn up Braid and dead ends get opened into loops. The maze stops being a tree, so “the” solution becomes “a” solution and there are now many routes. This is what most real mazes — hedge mazes, game levels — actually are, because a perfect maze is solvable by simply keeping one hand on the wall, and a braided one is not.

What will you try next?

Share this tool

Part of Shake AI Lab — interactive experiments in mathematics and machine learning. · More tools