How to play
The green square in the top-left corner is the start and the red square in the bottom-right corner is the exit. The blue circle is you. Move one cell at a time with the arrow keys, with W, A, S and D, or with the four on-screen buttons. If a wall blocks the direction you press, you hear a low buzz and nothing moves, and the move counter does not change. The counter only counts real steps, so walking into a dead end and back out counts every cell twice. The timer begins at your first successful step rather than when the maze appears, so you can study the layout for as long as you like without it costing time. It stops when you reach the exit, and cells you have crossed stay tinted light blue so you can see which branches you have already tried. Changing the difficulty or pressing "New maze" immediately builds a fresh maze and resets everything. No scores are saved and nothing is sent to a server.
Maze sizes
The three levels differ only in the width of the square grid. The values below are calculated from the same size constants the game code uses. The number of open passages follows from the maze being a connected structure with no loops: a connected set of N cells with no cycles always has exactly N minus 1 links. The interior walls that remain are the total number of cell boundaries, 2n(n minus 1), minus those open passages, which leaves (n minus 1) squared.
| Level | Grid | Cells | Open passages | Interior walls left | Canvas (px) |
|---|---|---|---|---|---|
| Easy | 11Γ11 | 121 | 120 | 100 | 352Γ352 |
| Normal | 17Γ17 | 289 | 288 | 256 | 408Γ408 |
| Hard | 23Γ23 | 529 | 528 | 484 | 460Γ460 |
Shortest-route reference table
Start and exit are always at opposite corners, so even with no walls at all you would need at least 2(n minus 1) moves. Real mazes wind around, so the true shortest route is much longer. The "simulated" columns are random-dependent values: they come from running this page's generator 3,000 times per size and measuring the shortest route each time, and they are rounded to give you a feel for the scale. Every maze you play is different, and running the simulation again gives slightly different numbers. The 10% columns and the median are the values at those positions in the sorted list of 3,000 results.
| Level | Theoretical minimum | Simulated minimum | Lowest 10% | Median | Top 10% | Wall-follower worst case |
|---|---|---|---|---|---|---|
| Easy | 20 | 20 | 32 | 52 | 78 | 240 |
| Normal | 32 | 40 | 68 | 112 | 164 | 576 |
| Hard | 44 | 60 | 112 | 190 | 274 | 1056 |
The "wall-follower worst case" column is an upper bound, not a measurement. A hand-on-the-wall strategy, which is described below, can traverse each passage at most twice in a maze with no loops, so it can never take more than 2 times (cells minus 1) moves. When you finish, the game shows the exact shortest route length for the maze you just solved next to your own move count.
Efficiency score and two checked examples
Efficiency is shortest moves divided by your moves, times 100. A score of 100% means you never took a wrong turn. Dividing by the shortest route for that particular maze makes scores comparable between mazes, which raw move counts are not: a lucky, short maze would otherwise look like skill.
- On Normal, take a maze whose shortest route happens to equal the simulated median of 112 moves. If you escape in 140 moves, efficiency is 112 Γ· 140 β 80%, which means 28 extra steps.
- The theoretical minimum on Normal is 32 moves, and a maze that allows it needs an almost straight layout, so it is extremely rare. Even 14 extra steps on top of 32 gives 32 Γ· 46 β 70%.
How the maze is generated, and how the shortest route is found
The generator is the well-known recursive backtracker, implemented with a loop and a stack instead of recursion. Every cell starts with four walls. The algorithm marks the start cell as visited, picks one of its unvisited neighbors at random, knocks down the wall between them and moves there. When a cell has no unvisited neighbors it pops back along the stack until it finds one that does. When the stack is empty every cell has been visited. The random choice uses the browser's Math.random, which is not a cryptographic generator, so this is for fun only and not for anything that needs unpredictability.
The result is a "perfect maze": every cell is reachable and there is exactly one route between any two cells. Because there are no loops, a maze without a solution cannot occur. Mazes from this method tend to have long, winding corridors with relatively few branches, which fits the table above, where the Normal median is more than three times the theoretical minimum.
The shortest route shown after you win is computed with breadth-first search the moment the maze is created. Starting from the start cell, it visits cells in order of distance, never entering a wall, and records each cell's distance. The distance recorded at the exit is the shortest number of moves. This costs time proportional to the number of cells, so even the 529 cell Hard maze is processed instantly.
Tips for escaping faster
- Wall following. Keep one hand, in your head, on the right-hand (or left-hand) wall and never let go. In a maze with no loops this is guaranteed to reach the exit, within the worst-case bound in the table. It is reliable but wasteful, because it walks every dead end to the bottom.
- Prefer right and down. The exit is always in the bottom-right, so at a fork try the branches that head right or down first. This is a rule of thumb, not a guarantee, but on average it reduces backtracking.
- Use the tinted trail. Visited cells are shaded, so you can see a dead end you have already explored and avoid walking into it again.
- Solve it with your eyes first. The Easy maze fits on screen at once. Follow the route backwards from the exit with your eyes; because there is only one route, the first fork you reach from the exit tells you which branch to take from the start.
- Tap, do not hold, near forks. Holding a key repeats moves quickly, which is fine in corridors, but a short tap at a junction avoids overshooting into the wrong branch.
Controls and display notes
The arrow keys and WASD are captured by the game, so the page does not scroll while you play and the difficulty menu does not change value when you press an arrow key. After you pick a difficulty the menu releases focus so you can start moving straight away. Keyboard shortcuts with Ctrl, Alt or the Command key are left alone. On a phone, use the four buttons under the board. The canvas shrinks to fit your screen width while keeping its internal resolution, but the Hard maze is 460 pixels wide, so on a small screen its lines look thinner.
Building your skill over time
Repeat the same level a few times and watch your efficiency percentage, not the raw move count. A score around 50 to 70 percent is a reasonable first target, since 100 percent means you saw the whole route before moving. The time is affected by your typing speed and device, so treat it as a secondary measure. On Hard, the tinted trail is especially useful, because the board is too large to read at a glance and checking each junction against it keeps you from repeating work.
Frequently Asked Questions
Does the maze have more than one path?
No. A maze built this way is a "perfect maze" with exactly one route between any two cells. There are plenty of forks, but no loops, so you can never walk around an obstacle. A dead end always means turning back.
Do bumps against walls add to my move count?
No. Pressing toward a wall only plays a sound. The counter increases only when your character actually changes cell.
When does the timer start?
On your first successful step, not when the maze appears, so time spent studying the layout is free. It stops at the exit and shows the final time to one decimal place.
Can I play on a phone?
Yes. The on-screen buttons under the board move your character one cell per tap, so no keyboard is needed.
Can I replay the same maze?
No. Each maze is generated at random and not stored, so the same layout will not come back. Reloading the page or changing the difficulty discards the current maze.
More puzzles to try
- Nonogram puzzle: fill a grid using number clues
- Sudoku: a classic logic puzzle
- Snake: steer through a grid without hitting yourself
- Memory match: find pairs of cards