What Is a Maze Puzzle? Paths, Walls, Dead Ends and How to Solve One
This article was written with AI and may contain mistakes. Found one? Tell us.
A maze puzzle is a network of paths divided by walls, with a start, a goal and choices along the way, and your task is to find a route from the start to the goal. What makes it a puzzle rather than a walk is the dead ends: many turnings lead nowhere, and only careful choosing gets you through.
This article explains the parts of a maze, how it differs from a labyrinth, the main kinds, and how a maze becomes a graph of points and lines. It then looks at how people and machines find their way, solves a small maze step by step with a computer search, and ends with what separates a good maze from a dull one.
What are the parts of a maze?
Every maze, from a pencil puzzle to a hedge garden, is built from the same five parts.
Paths. The open corridors you may travel along. On paper they are the blank spaces between the lines. In a garden they are the walks between the hedges.
Walls. The barriers you may not cross. Walls do the real work of a maze, because they decide which places connect and which do not.
A start. The single place where you enter. It may be marked with an arrow or a gap in the outer wall.
A goal. The place you must reach. It may be a second gap in the outer wall, or a spot hidden in the middle.
Dead ends. Corridors that stop with no way forward. A dead end forces you to turn back, and a maze with many of them hides its true route well.
Two more words help. A junction is any place where the path splits into two or more choices. The solution path is the chain of corridors that leads from the start to the goal without crossing a wall.
How is a maze different from a labyrinth?
In this article the two words mean different things. A labyrinth, as the word is used here, has a single path. It winds and doubles back, often filling a whole circle or square, but it never splits, so walking it takes patience rather than decisions. You cannot get lost in a true labyrinth, because every step carries you on toward the centre.
A maze is built around choice. Its path branches at junctions, some branches stop at dead ends, and some may loop back on themselves. Solving it means deciding, again and again, which way to go.
| Feature | Maze | Labyrinth |
|---|---|---|
| Number of paths | Many branches | One single path |
| Junctions | Yes, the heart of the puzzle | None |
| Dead ends | Usually several | None |
| Can you take a wrong turn? | Yes | No, only forward or back |
| Main challenge | Choosing | Keeping your place to the end |
A labyrinth is closer to a tangle of cords: there is only one line to follow, and the work lies in not losing track of it.
What kinds of mazes are there?
Mazes come in many forms. Some names describe the shape of the layout, and others describe the way the paths connect.
| Kind | What sets it apart | What it feels like to solve |
|---|---|---|
| Perfect maze | Exactly one route between any two places, no loops | Every wrong turn ends in a dead end |
| Braid maze | Loops in place of most dead ends | You can wander in circles |
| Grid maze | Square cells with walls along their sides | Tidy and easy to draw on squared paper |
| Circular maze | Rings of paths around a centre | Hard to judge which ring leads inward |
| Weave maze | Paths pass over and under one another | You track bridges as well as turns |
| Multi-level maze | Floors joined by stairs or ramps | The flat drawing hides how places connect |
| Rule maze | Arrows, colours or other rules limit your moves | Some of the walls live in the rules |
The worked example further down is a perfect maze. Because it has no loops, there is exactly one way from the start to the goal that never doubles back, and every other branch ends in a dead end. A braid maze swaps dead ends for loops, so instead of being stopped you are tempted to walk in circles.
Rule mazes are the most puzzle-like of all. The paths may be wide open, but a rule such as follow the arrows, or never turn left, cuts down the moves you may take. The hardest walls are the ones you have to remember.
How does a maze turn into a graph?
A maze can be described as a graph: a set of points, some of them joined by lines. The trick is to keep only the places where something happens. Each junction, each dead end, the start and the goal become points, and each corridor that links two of them becomes a line. The bends of a corridor do not matter, only which two points it joins.
Board puzzles can be described the same way. A chessboard graph, as defined in a paper dated 7 December 2021, has one point for every square and a line between two squares whenever a piece can move directly from one to the other [1].
In that language, a walk is a chain of points each joined to the next, the distance between two points is the length of the shortest path between them, and the diameter is the largest distance between any two points of the graph [1].
The knight's tour shows how much the graph view simplifies a board puzzle. A paper published on 9 May 2007 explains that once the board is written in graph terms, asking for a closed tour, one that visits every square once and returns to its start, becomes asking whether the graph has a loop through every point [2].
A maze fits the same pattern. Solving it means finding a chain of lines from the start point to the goal point. A dead end is simply a point touched by only one line, and a junction is a point touched by three or more. Once a maze is drawn this way it shrinks a great deal, because a long winding corridor becomes a single line.
How do people and machines solve a maze?
There are several hand methods. One is the wall follower: put one hand on a wall and never lift it. It is not certain to work in every maze, but in the worked example below both hands do reach the goal, each by a detour.
On paper, you can work from both ends at once, or shade every dead end back to the junction where it starts until only the true route is left. In a walk-through maze, you can mark each corridor as you use it, so you never walk the same one twice in the same direction.
A computer can solve a maze by searching its graph. Breadth-first search starts at the start and labels every cell one step away, then every cell two steps away, and so on, like a ripple spreading across a pond. The first time the ripple touches the goal, the label it carries is the length of the shortest route.
| Method | How it works | Finds the shortest route? | Copes with loops? |
|---|---|---|---|
| Wall follower | Keep one hand on the same wall | Not usually | Can circle forever around a free-standing loop |
| Dead-end filling | Shade each dead end back to its junction | Yes, in a perfect maze | Leaves loops unfilled |
| Marking corridors | Mark each corridor you use and avoid repeats | No | Yes |
| Depth-first search | Follow one branch to its end, then back up | No | Yes, if visited cells are remembered |
| Breadth-first search | Spread out one step at a time from the start | Yes | Yes |
Machines that move through real mazes face an extra problem: they must first sense where the paths are. A 2021 paper described a small two-wheeled robot that drove through a test maze by following a black guide line on a light surface [3]. The paper reports that the robot used 5 reflectance sensors to tell the dark line from the pale area around it, and coded each reading as a binary digit [3].
Its neural network had one output for each of the two motors, and those outputs went straight to the robot's motion system [3].
The network was trained by back-propagation on ten sensor patterns, and it had no hidden layer, since the small processor had limited computing power and the chosen activation function was demanding to compute [3]. The robot drove until it found the end of the maze, marked by a wide black strip across the lane, and stopped there [3].
That robot learned to steer along a line rather than to plan a route, and the paper points to separate work for algorithms that explore a maze [3]. It also reported that back-propagation gave the same result in the maze as an older learning rule trained on the same patterns, with the advantage that it can use more training patterns [3].
Can you solve a small maze step by step?
Here is a small grid maze of seven rows and seven columns. A filled square is a wall, a dot is an open cell, and you may move one cell at a time up, down, left or right. The columns are lettered from left to right.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| one | Start | · | · | ■ | · | · | · |
| two | ■ | ■ | · | ■ | · | ■ | · |
| three | · | · | · | · | · | · | ■ |
| four | · | ■ | ■ | ■ | ■ | · | ■ |
| five | · | · | · | ■ | · | · | · |
| six | ■ | · | ■ | ■ | · | ■ | · |
| seven | ■ | · | · | ■ | · | ■ | Goal |
The maze has thirty open cells and nineteen walls. Breadth-first search labels the start with zero, its neighbour with one, the next cells with two, and keeps going. The goal receives the label twelve, so the shortest route takes twelve moves, and no other route of that length exists.
The route itself is easy to read once you know it. Go right two cells along row one, down two cells to row three, right three cells along row three to column F, down two cells to row five, right one cell to column G, and down two cells to the goal.
Everything else is a decoy. The maze hides four dead ends: the pocket that ends in row two of column G, reached by climbing from row three through column E and around the top right corner; row five of column C; row seven of column C; and row seven of column E. It also has four junctions, at row three columns C and E and at row five columns B and F.
Drawn as a graph, the maze shrinks to ten points, namely the start, the goal, the four junctions and the four dead ends, joined by nine lines. Every open cell can be reached from the start, so the graph is connected, and a connected graph with one fewer line than points has no loops. That makes this a perfect maze.
By the time the search finishes the cells twelve steps from the start, it has labelled all thirty open cells, because no open cell lies farther away than that.
How do the hand rules compare? Walking the maze cell by cell, starting at the top left corner facing right, gives these results.
| Method | Moves to reach the goal | Shortest? |
|---|---|---|
| Breadth-first search route | twelve | Yes |
| Left-hand wall follower | twenty-two | No |
| Right-hand wall follower | thirty-six | No |
Both hands get there, because the maze has no loops, but the right hand wanders into three of the four dead ends before it finds the way. The breadth-first route is the only one with no doubling back.
What makes a good maze?
A good maze is fair, has a single answer, and makes you work for it. These are the qualities that separate a satisfying maze from a dull one.
One clear start and one clear goal. The solver should never wonder where to begin or whether they have finished.
A single solution. A perfect maze has exactly one route without doubling back, so there is no question about the answer.
Tempting dead ends. The best decoys look as promising as the real path. A dead end that runs a long way before it stops costs the solver more than a short stub.
A route that does not hug the edge. If the true path runs along the outer wall, a wall follower finds it at once and the puzzle collapses.
Walls that stretch distances. Walls are what turn a short trip into a long one. The chessboard paper shows how strong a single block can be: a rook on an empty board reaches any square in two moves, but one blocking piece on a square that is not a corner already forces some trips to take three [1]. A maze maker uses the same effect on purpose, placing walls so that places that look close are far apart in moves.
A size that suits the solver. A few junctions make a quick warm-up. Many junctions and long decoys make a maze worth a quiet half hour.
Which maze puzzles can you try now?
You now know what a maze puzzle is: paths, walls, a start, a goal and the dead ends in between, all of which you can picture as points joined by lines. Try spotting the junctions before you move, count how many choices each one gives you, and see whether you can name the shortest route before you trace it.
The puzzles below ask you to choose a road, follow a path and keep track of where each turn leads.
References
- Chatham, D. (2021, December 7). Diameter-Separation of Chessboard Graphs. Recreational Mathematics Magazine, 8(15), 13-26. DOI 10.2478/rmm-2021-0008
- DeMaio, J. (2007, May 9). Which Chessboards have a Closed Knight's Tour within the Cube?. The Electronic Journal of Combinatorics, 14(1), R32. DOI 10.37236/950
- Horváth, D., & Červeňanská, Z. (2021, December 7). Controlling a Small Mobile 3-Pi Robot Movement in a Maze via the Neural Network Using Back-Propagation Learning Method. Research Papers Faculty of Materials Science and Technology Slovak University of Technology, 29(49), 43-50. DOI 10.2478/rput-2021-0023