The playable example validates its original five-by-seven map, moves one cardinal cell at a time and records successful steps. Two different eight-step routes reach the exit. A separate isolated-exit scenario is rejected before play, and winning freezes movement until Reset.

Separate map, game state, and rendering
Brown University's maze project separates configured map and evolving game state from rendering and movement, including walls that cannot be crossed. The map below applies that separation to a small grid you can trace by hand. Brown CS: Maze Project
Use these five original map strings in order:
########S..#E##.#.#.##.....########
The symbols are wall #, floor ., start S, and exit E. Coordinates are one-based: the start is row 2, column 2; the exit is row 2, column 6. S and E are traversable cells; their labels remain separate from the player's current position.
Keep the map unchanged during movement. Store the player position separately from the map. When P moves away, the original floor or exit must still be there. Keep a successful-move count and a status such as Playing, Won or Invalid map alongside that position.
Validate shape, symbols, and reachability
Before enabling play, check equal row lengths, known symbols, exactly one S and one E, and traversable start and exit. Then perform a reachability check through cardinally adjacent traversable cells from S.
The validator uses a queue to visit reachable cells, tracking each one once and respecting walls and bounds. Play begins only if that search reaches E.
For the original map, the route below demonstrates reachability manually. For an invalid variant, replace row 3, column 6 with a wall. E then has walls above, below, left, and right, so it is isolated. Reject that map before play rather than reporting a completed or merely difficult game.
Trace eight legal moves
Use this reference route:
| Step | Direction | Arrival position |
|---|---|---|
| Start | — | (2, 2) |
| 1 | Right | (2, 3) |
| 2 | Right | (2, 4) |
| 3 | Down | (3, 4) |
| 4 | Down | (4, 4) |
| 5 | Right | (4, 5) |
| 6 | Right | (4, 6) |
| 7 | Up | (3, 6) |
| 8 | Up | (2, 6), exit |
Every arrival is a supplied floor or exit, and each move changes exactly one coordinate by one. The route reaches E in eight successful steps.
It is not the only route. Another eight-step path goes from (2, 2) down to (3, 2), then (4, 2), across (4, 3), (4, 4), (4, 5), (4, 6), and up through (3, 6) to (2, 6). Do not reject it because it differs from the reference list.
From (2, 4), Right targets (2, 5), a wall. Position remains (2, 4), and the successful-move count remains unchanged. Explain the blocked target; do not silently move around it or charge it as a successful step.
Play and inspect the boundary
Use the direction buttons or focus the board and press fresh arrow keys. Held-key repeats are ignored. Starting at (2, 2), move Right twice, then try Right again: the target (2, 5) is a wall, so the position and successful-step count stay unchanged. Continue Down, Down, Right, Right, Up, Up to reach the exit in eight successful moves.
Press Inspect isolated exit to replace row 3, column 6 with a wall. The validator reports that the exit is unreachable and rejects movement. Reset restores the original valid map, starting position, zero moves and an empty turn history. A rejected map is different from a completed game. Read the displayed step history to compare the two routes, counting only arrivals that changed the player’s cell.
Copy this prompt
Create one playable HTML maze with a compact grid, direction buttons and a readable movement history. Use these five map rows in order: #######, #S..#E#, #.#.#.#, #.....#, #######. A hash is a wall, a dot is floor, S is the start and E is the exit. Display coordinates starting at one, so S is at row 2, column 2 and E is at row 2, column 6.
Before play, validate the rectangular shape, allowed symbols, exactly one start and exit, and reachability through horizontal or vertical floor neighbors. Use a queue and a visited set. A valid map starts in Playing with zero successful moves.
Give Up, Down, Left and Right buttons one shared movement function. Fresh arrow presses also work while the board is focused. Reject a wall or boundary without moving the player or adding a successful step. Show the blocked coordinate in a message. Keep the underlying S and E map values separate from the player marker.
The route Right, Right, Down, Down, Right, Right, Up, Up reaches E in eight moves. Down, Down, four Right and two Up is another valid eight-move route. Accept either. Reaching E changes the status to Won and stops further movement.
Add Inspect isolated exit, which replaces row 3, column 6 with a wall. Show that E is unreachable and disable play. Reset original map restores the valid grid, starting position, zero moves and empty history. Return a self-contained HTML file with distinct wall, floor, player and exit styling, text labels and a grid that fits a narrow phone screen.
Compare two routes to E
Follow the route beginning Right, Right, then reset and try the route beginning Down, Down. Both take eight successful steps. NOS can render the HTML maze for a movement-rule walkthrough. Stop at (2, 4), try the wall to its right and explain why the next successful step is still number three.