Skip to content

Maze Basics

How Mazes Work

Learn how maze paths, walls, dead ends, loops, and generation algorithms create the puzzles you solve.

The anatomy of a maze

Every maze — whether printed on paper or rendered on screen — is built from the same basic parts.

Paths

The open corridors you move through. Paths connect cells and define where you can go.

Walls

The boundaries that block movement. Walls are what create the puzzle — without them, there is nothing to navigate.

Dead ends

Corridors with only one opening. You can enter a dead end but the only way out is back the way you came.

Junctions

Points where three or more paths meet. Junctions force a decision — which direction to go next.

Entry

Where you start. Usually marked on the edge of the maze grid.

Exit

Where you need to reach. The goal of every maze.

Understanding these parts makes it easier to talk about strategy. When you reach a dead end, you know it is definitively not part of the solution. When you reach a junction, you face a real decision. The structure of the maze is the puzzle.

Perfect mazes and mazes with loops

Not all mazes are structurally identical. The most important distinction is whether a maze is perfect or contains loops.

Perfect maze

  • Every cell is reachable from every other cell
  • Exactly one path exists between any two points
  • No loops — no place where two paths reconnect
  • Has a single, definitive solution

Maze with loops

  • Extra walls removed to create multiple connected paths
  • More than one route from entry to exit
  • Generally easier to navigate — more options at each junction
  • Dead-end filling becomes less effective as a solving strategy

Most puzzle mazes — including all mazes generated by MazePuzzles.io by default — are perfect mazes. Loops are sometimes added to easier difficulty levels to give solvers more room to maneuver when they get stuck.

How mazes are generated

A computer-generated maze starts as a grid of cells, each completely surrounded by walls. The generation algorithm selects which walls to remove, carving out a connected network of paths while preserving the structure of a perfect maze.

MazePuzzles.io uses the recursive backtracker — also called depth-first search — for all its mazes. Here is how it works:

  1. 1 Start at a random cell: Mark it as visited. This is the seed of the maze.
  2. 2 Choose a random unvisited neighbor: Carve a passage (remove the shared wall) and move into it.
  3. 3 Repeat until stuck: Keep carving deeper into unvisited territory. This is the "depth-first" part.
  4. 4 Backtrack when stuck: When all neighbors are visited, step back to the previous cell and try again.
  5. 5 Finish when all cells are visited: Every cell has been reached exactly once. The result is a perfect maze.

What this produces

The recursive backtracker creates mazes with long, winding corridors and many dead ends. Because the algorithm dives deep before backtracking, it tends to produce a strong visual flow — long diagonal runs followed by forced turns. This makes the mazes feel dramatic and satisfying to navigate.

What this means for solving

Knowing how a maze was generated helps you choose the right solving strategy.

Recursive backtracker mazes are perfect mazes — which means the wall-following rule (keeping one hand on the wall) is guaranteed to reach the exit. Dead-end filling also works well: the dense dead-end structure gives you a lot of paths to eliminate, and each elimination simplifies the remaining puzzle significantly.

When scanning a large maze before you start, look for the telltale signs of DFS structure: long unbroken corridors that run across significant portions of the grid. Those long passages are strong candidates for the solution path because the algorithm tends to carve the main corridor deep before branching.

For more on how to apply this — and the other strategies that work across maze types — see the full solving guide.

How to Solve a Maze →

Size, difficulty, and wall removal

Grid size is the most visible factor in difficulty, but it is not the only one. Two 40×40 mazes can feel very different depending on their internal structure.

Grid size

More cells means more surface to cover and a longer solution path. A 60×60 maze has nine times the area of a 20×20 maze.

Corridor length

Long winding corridors are harder to track mentally than short frequent ones. DFS mazes have the longest average corridors.

Wall removal

After generation, removing extra walls creates loops. Loops make dead-end filling less effective and give solvers more options — easier, but less systematic.

The best way to understand these differences is to solve mazes at different sizes back to back. What feels manageable at 20×20 feels like a different puzzle entirely at 60×60 — even though the underlying structure is generated by the same algorithm.

Try a maze at every size

The best way to understand maze structure is to solve a few. Start small, notice the patterns, then step up.

Frequently asked questions

What is a perfect maze?
A perfect maze has two properties: every cell is reachable from every other cell, and there is exactly one path between any two points — no loops. Perfect mazes are the most common type in puzzles because they have a single, definitive solution.
Can a maze have more than one solution?
Yes. A maze with loops — where extra walls have been removed to create multiple connected paths — can have more than one route from entry to exit. These are called imperfect mazes. They are generally easier to navigate but harder to analyze systematically because dead-end filling does not eliminate all wrong paths.
What algorithm does MazePuzzles.io use to generate mazes?
MazePuzzles.io uses the recursive backtracker (depth-first search) algorithm for all its mazes. It produces long winding corridors and a high density of dead ends, which makes for dramatic, satisfying puzzles. For easy and kids mazes, extra wall removals are applied after generation to create loops and reduce difficulty.
What is a dead end in a maze?
A dead end is any corridor that has only one opening — you can enter it, but the only way out is back the way you came. Dead ends are definitively not part of the solution path in a perfect maze, which makes them useful targets for the dead-end filling strategy.
What is a junction in a maze?
A junction is any point where three or more paths meet, requiring a decision about which direction to go. Junctions are the decision points that create the challenge of a maze. A maze with more junctions generally feels more complex, even if the grid size is the same.
Why do some mazes feel harder than others?
Several factors affect perceived difficulty: grid size (more cells = more surface to cover), corridor length (longer winding paths are harder to track mentally), dead-end density (more dead ends = more wrong turns), and the presence or absence of loops. The recursive backtracker creates long corridors and many dead ends, which makes mazes feel demanding even at moderate sizes.
Can I generate a maze myself?
Yes. The Maze Generator on MazePuzzles.io lets you set the size and generate a fresh maze instantly. Each maze is unique — the same algorithm, a different random seed. You can play it in your browser, print it as a worksheet, or download the SVG.

Ready to see it for yourself?

Generate a maze and watch the structure in action, or browse the library to compare sizes.