Maze
A maze you can actually walk: use the arrow keys / WASD or click an open neighbouring cell to get from the top-left corner to the exit in the bottom-right. The maze comes from a seed (recursive backtracking, always connected) and the page tracks steps, wall bumps and the BFS shortest distance to the exit.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Maze board
Press the arrow keys / WASD to step, or click an open cell right next to you; walls block the move and count as a bump.
- Steps
- 0
- To the exit
- 78
- Bumps
- 0
- Cells walked
- 1
- Size
- 21×15
- Walls
- 176
Arrow keys / W A S D: step up, down, left or right; you can also click an open cell right next to you.
Move log
0 steps this maze
No moves recorded yet
What this tool does
- Walk the maze right here: step with the arrow keys / W A S D or click an open cell next to you, and reach the exit in the bottom-right corner to win.
- Reproduce the same maze from a seed: the same seed and size give the same walls cell by cell, which is handy for comparing routes or bump counts.
- Take the short way: press Hint for the first cell of the BFS shortest path and how many steps remain, or switch on "Show the BFS shortest path" to draw the whole route on the board.
Example
Input
maze seed demo · 21 columns × 15 rows · show the BFS shortest path
Output
Step 0 · bumps 0 · 78 steps to the exit BFS shortest path: 78 steps (# wall, o shortest path) ##################### #ooooo#ooooo# ooo# # #####o#o###o###o#o# # # #ooo# #ooooo#o# # # ####### #######o# # # # # #ooooo#o# # # # # # # #o###o#o# # # # # # #o #o#o# # # # ##### #o###o#o# # # # #o#ooo#ooo# # ### #####o#o#####o# # # # #ooooo#ooooooo# # # # #o############# # # ooooooooooooo# #####################
The maze and the shortest path are computed on the spot: recursive backtracking carves the corridors from the seed and BFS finds the 78-step route from the top-left corner to the exit in the bottom-right.
Frequently asked questions
How do I play, and what does winning look like?
Click the board and press the arrow keys / W A S D (or click an open cell right next to you). Every successful step counts; reaching the exit just inside the bottom-right corner wins, and the page then shows "You escaped the maze!" with your step and bump counts. A wall blocks the move but is counted as a bump, and the status line and stats are the real numbers of the current position.
Is the maze always solvable?
Yes. Recursive backtracking only carves odd cells, so any two open cells connect; the start (1,1) and the exit (height-2, width-2) are both on corridors. Each side is forced to an odd number (an even value rounds up) and can be 5–51.
How are the shortest path and the hint computed?
Both are a real BFS: it expands from your current cell, so the first arrival at the exit is the shortest route. The hint returns the first cell of that route and the remaining steps, not an estimate; the "Show the BFS shortest path" switch only draws that route on the board.
Is the maze random, and can I reproduce one?
It is not random: the maze is fully determined by the seed (through xorshift128) plus the size, so the same seed always gives the same maze. "New maze" re-generates from your inputs, while "Restart this maze" reuses the same parameters and reproduces the previous maze exactly.
Is anything uploaded, and how big can the maze be?
Everything runs in your browser: no network requests and no localStorage writes, so a reload starts over. Columns and rows accept 5–51 (even values round up to odd) with 21×15 as the default; bigger boards mean more cells and a little more work.
Keywords:mazeBFS