Maze generator

How to Create Your Own Maze With an Online Maze Generator

A maze generator is useful when it actually builds a graph, not when it shuffles a folder of pictures. Maze Foundry represents every puzzle as cells (vertices) and passages (undirected edges). Walls are missing connections. After you press Generate maze, the workshop validates connectivity and an entrance-to-exit route. That is the difference between a drawing and a puzzle you can solve, print, or export.

Understanding maze structures

Start with the idea of a grid. In a rectangular maze each cell may connect north, east, south, or west. The identifier is cellId = row × columns + column. East and west never wrap around the row. Circular mazes use rings and sectors. Hexagonal mazes use axial coordinates (q, r). The shared rule is the same: a passage must join two adjacent cells, both ways, never a cell to itself.

A perfect maze is a spanning tree. For N cells it contains N − 1 internal passages and no cycles, so there is exactly one simple path between any pair of cells. A 20 × 20 perfect rectangle has 400 cells and 399 internal passages. Braided mazes start from that tree and open extra walls at a target share of initially identified dead ends. Cycles can appear; the count for a connected graph is E − V + 1. Braided puzzles can have several valid solutions. The workshop never removes outer boundary walls except for the chosen entrance and exit openings.

Choosing a maze shape

Use the Maze shape control. Rectangular mazes match printed puzzle books. Circular mazes are polar grids drawn with SVG arcs, not stretched squares. Hexagonal mazes are honeycombs with six-direction adjacency. Open the circular generator or the hexagonal generator when you want topology-specific notes. Presets 13–18 and 19–24 on the preset gallery load fixed seeds for those shapes.

Selecting grid dimensions

Rectangular limits are 5 × 5 through 100 × 100, with a hard cap of 10,000 cells. Circular rings run from 3 to 20. Hexagonal radius runs from 2 to 30. The site will not silently shrink a request. Wilson’s algorithm on large boards can be cancelled; an incomplete walk is not shown as a finished maze.

Three practical sizes

Small. Generate 7 × 7, randomized depth-first search, seed 101 — the First Steps preset. You can count dead ends by hand and compare them with the Inside this maze ledger.

Medium. Keep the default 20 × 20, algorithm DFS, seed 505 — Classic Square. Expect 400 cells. Read shortest solution length and solution coverage from the live statistics; do not assume a larger grid is automatically harder.

Large. Try 60 × 60 Expert Workshop, seed 1212. Generation time is measured on your device with performance.now and is labeled as generation, not rendering. A large maze can still have a relatively short shortest path.

Choosing entrance and exit positions

Rectangular presets include top-left to bottom-right, top-right to bottom-left, left-center to right-center, top-center to bottom-center, random distinct boundary cells, and custom boundary cells. Circular options include outer-to-center and opposite outer openings. A center goal does not get a fake exterior hole. Hexagonal options include opposite boundary regions and random distinct boundary cells. Start and goal must be distinct valid cells. START is a circle with a text label; FINISH is a square with a text label, so color is not the only cue.

Understanding generation algorithms

Four methods share the graph engine: randomized depth-first search (an iterative recursive backtracker), randomized Prim, randomized Kruskal with union-find, and Wilson’s loop-erased random walks. None is universally harder. Compare dead ends, junctions, and solution length in the algorithm laboratory. Identical seeds do not imply identical random streams across algorithms.

Using random seeds

Type a number or a phrase. Text is hashed with FNV-1a into an unsigned integer, then Mulberry32 produces the sequence. Randomize seed uses the browser’s native random source and displays the actual value so you can copy it. The same seed, dimensions, algorithm, maze type, braid setting, entrance mode, and generator version 1.0.0 rebuild the same topology. Colors do not. This is not cryptographic randomness, and different seeds can collide on the same structure.

Adjusting approximate difficulty

Very Easy 7 × 7, Easy 12 × 12, Medium 20 × 20, Hard 35 × 35, and Expert 60 × 60 are size-and-algorithm shortcuts. They are not a scientific difficulty score. A 12 × 12 maze can have a longer shortest route than a 20 × 20 maze depending on the spanning tree. Always read the measured ledger: cells, passages, dead ends, junctions, shortest length, coverage, cycles, seed, and algorithm.

Customizing walls and colors

Wall color, background color, solution color, wall thickness, cell size, and cell aspect ratio redraw the current maze. Changing those controls does not carve new passages. Puzzle title is escaped in SVG so it cannot inject markup.

Revealing a solution

Show solution draws the shortest unweighted route through open passages in #C46A49 by default. Hide solution removes it. Every consecutive pair of path cells is a real graph edge. Play this maze sends the same graph to the challenge page.

Exporting and printing a maze

Download SVG writes standalone geometry with a correct viewBox. Download PNG rasterizes at 800, 1600, 2400, or 3200 pixels while preserving aspect ratio. Puzzle exports omit the solution; solution exports include it. Export configuration writes versioned JSON (maze-foundry-config). Import validates types and ranges and never executes scripts. Print maze uses the browser print dialog, including save as PDF.

FAQ

Do I need an account to use the maze generator?
No. There are no accounts, payments, or generation caps.
Will every generated maze have a path?
Finished mazes are validated. Cancelled jobs are not presented as complete.
Can I recreate a puzzle later?
Yes — copy the seed or export the configuration file.

Continue with the rectangular workshop or the article on generation algorithms.