Behind the Maze

How can one 11-character code rebuild the exact same maze?

Start 3D Maze Game
On this page

Every maze is rebuilt in your browser from a short code. The browser generates the walls and passages itself, so you and a friend can play the same maze without downloading a saved maze layout. Global rankings store the maze code alongside submitted records.

This page walks through seeds, maze codes, and the generation algorithm. There's a little math involved, but it's written to be an easy read.

The seed — where a maze begins

Mazes are built from random numbers, but those numbers are pseudorandom: each one is derived from a starting value called the seed, and the same seed always reproduces the exact same sequence.

That's why the seed and the difficulty are all it takes to rebuild the entire maze: every wall, the start, and the goal. Open it on any device in any country and the result matches down to the last bit. To avoid floating-point drift, the generator uses integer math only.

Anatomy of a maze code

A maze code looks like M1-7-03NQK8N5. Strip the hyphens and you have exactly 11 characters: a leading M, one character for the format version, one for the difficulty, seven for the seed, and one final check character.

The characters come from a set called Crockford Base32: the digits 0 through 9 plus the uppercase alphabet minus I, L, O, and U. Leaving out the easily confused letters makes codes easier to write down or read aloud, and if you do write an O by mistake, it's simply read as a 0. Lowercase, hyphens, and spaces are all fine too.

The last character is a checksum, calculated from the preceding characters by a fixed rule. It helps catch common typing mistakes, but it cannot detect every possible error. A shared link or QR code avoids having to copy the code by hand.

How a maze grows

The generation algorithm is Growing Tree. Starting from one cell, it carves passages into neighboring cells, growing outward like a tree. Always extending from the newest cell produces long, winding corridors; extending from a random cell produces lots of branching. The difficulty decides how those two tendencies are blended.

Some difficulty levels open extra passages out of dead ends, creating loops and alternative routes. Levels 5–7 keep a tree layout without these extra passages. Loops change the choices you face; their share does not simply rise at every level.

The start and goal are chosen on the border using distance searches to place them far apart. If the solution path is shorter than the level's target, the generator retries up to eight times, stopping when the target is met. Otherwise it keeps the last result. Every maze is solvable, and the fixed rules mean the same code always gives the same maze.

What difficulty 1 to 20 controls

Difficulty changes both the size and the shape of a maze. Level 1 is 8×8, level 10 is 40×40, and level 20 is 60×60. Size and the target solution length increase, while the balance of winding corridors, branching, and loops varies by level. A higher level does not mean that every one of those features increases.

Sharing with a short code

A share link or printed QR code contains the page address and the maze code, rather than a full wall-by-wall layout. The receiving browser rebuilds the maze from that code. Even the largest 60×60 maze can be represented by the same 11-character code format.

Start 3D Maze Game