Maze Generator
Make a printable maze in four shapes and three difficulties. Every maze has a seed so you can reprint the same one, with an optional solution and an SVG download.
This is the 20 x 20 maze for seed 633232. Enter that seed again to print the identical maze, on this device or any other.
How the maze is built
The generator starts from a solid grid of walls and carves a path through it using a recursive backtracker. It walks to a random unvisited neighbour, knocking down the wall between them, and when it runs out of moves it reverses along its own trail until it finds a cell with somewhere new to go. Every cell gets visited exactly once, so every maze is fully connected and there is always a way through. The winding corridors this produces are what makes a backtracker maze feel like a maze rather than a lattice of short stubs.
What difficulty actually changes
Difficulty here is not a vague slider, it is the proportion of dead ends that get opened up. Hard leaves the maze exactly as carved, a perfect maze with one route and the most wrong turns to fall into. Medium reopens a quarter of the dead ends and easy reopens seventy per cent, which turns those blind corridors into loops you can pass straight through. On a 20 x 20 grid that works out at roughly 42 dead ends on hard, 32 on medium and 14 on easy, and the shortest route shortens from about 143 steps to 67. The counts for the maze on screen are shown above it, so you can see what you actually got.
Rectangles, circles, diamonds and triangles
The four shapes are outlines cut from the same square grid: any cell whose centre falls outside the outline is simply left out before carving begins. A 20 x 20 grid gives 400 cells as a rectangle, 316 as a circle, 220 as a diamond and 200 as a triangle, so a shaped maze is smaller and a little quicker than a rectangle of the same nominal size. Because cutting a shape can leave a cell or two marooned in a corner, the generator keeps only the largest connected group and carves that, which is why a shaped maze is never accidentally missing a piece.
Seeds and reprinting the same maze
Every maze is generated from a seed, and the seed is shown with the result. Type the same seed with the same size, shape and difficulty and you get exactly the same maze, today or next term, here or on another computer. That is what makes this practical for a classroom: hand out the maze, keep the seed, then print the solution later from the same settings with the solution box ticked. A seed can be a word rather than a number, so year4-monday works as well as 481029.
Worth knowing
- The green dot is the entrance and the red dot the exit; the outer wall is opened at both.
- The drawing is measured in millimetres, so printing at 100% gives a true size sheet.
- The SVG download is a vector, so it stays sharp at any size and can be edited afterwards.
- The solution shown is the shortest route, which matters on easy where loops give more than one way.
- Nothing is stored. The maze is generated on our server and the result is discarded once it is sent.