Play now

What Is a Perfect Maze?

If you've read about maze generation you'll have seen the term "perfect maze." It has a precise meaning, and it's the reason the mazes you play are always fair.

The definition

A perfect maze (mathematicians call it a "simply connected" maze) is one where there is exactly one path between any two cells. That single rule has two consequences: there are no loops (you can never go in a circle back to where you started without retracing your steps), and there are no closed-off areas (every cell is reachable). In graph terms, the maze is a spanning tree of the grid.

Why it matters

  • Always solvable. Since every cell connects to every other, there's always a route from entrance to exit.
  • One true solution. There's a single shortest path, which makes for a clean puzzle and a satisfying optimal replay.
  • Wall-following works. Because all walls connect to the boundary, the wall-follower rule always reaches the exit.

How perfect mazes are made

Any algorithm that carves passages only into unvisited cells produces a perfect maze — most commonly the recursive backtracker. Every maze MazeWalker generates is perfect, so whatever you generate or scan from a photo, you know it can be solved.