About mazes - from ancient labyrinths to generated puzzles
People have drawn and built mazes for thousands of years, from the labyrinth of Greek legend to hedge mazes in gardens. Today a computer can grow a new maze in a split second, and the methods it uses are a neat example of how simple rules create complex shapes.
Labyrinths and mazes
A classic labyrinth has a single winding path with no choices. A maze has branches and dead ends, so you have to decide which way to go. Hedge mazes became popular in European gardens from the 16th century, and maze puzzles on paper have been a favourite ever since.
Perfect mazes
A perfect maze has no loops and no closed-off areas: there is exactly one route between any two cells. In maths terms its passages form a spanning tree of the grid, so a maze of n cells has exactly n - 1 openings between cells.
How a computer grows a maze
The recursive backtracker walks through the grid at random, knocking down walls into cells it has not visited, and steps back when it gets stuck. It makes long corridors with few branches. Prim's algorithm instead grows the maze from one cell outwards, joining a random neighbouring cell each time, which gives many short dead ends.
Solving tips
In a perfect maze you can always reach the exit by keeping one hand on a wall and following it. It is not the shortest way, but it always works. Looking ahead from the exit back towards the start can also help, and a breadcrumb trail stops you from walking the same dead end twice.
Frequently asked questions
What is the difference between a maze and a labyrinth?
A labyrinth has one path without choices; a maze has branches and dead ends. In everyday speech the two words are often used for the same thing.
Does the wall-following rule always work?
In a perfect maze it does, because all walls are connected. In mazes with loops you can walk around an island forever.
How big can a maze get?
Here up to 100 x 100 cells, which is 10,000 cells with a single route between start and exit.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Play Maze