Afterglowscreensavers

Maze Screensaver

Maze is a free, in-browser screensaver that carves a fresh random maze one passage at a time, then solves it from corner to corner before dissolving and starting again. The whole cycle — generation, solving, reset — loops forever using real maze algorithms, not a pre-drawn image. It runs full-screen with no download, and ESC exits.

Live preview

Maze screensaver — Carved, solved, repeat.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Maze screensaver works

The maze is carved with a recursive backtracker, the classic depth-first generation algorithm. Starting from the top-left cell, the screensaver repeatedly steps to a random unvisited neighbour, knocking down the wall between them, and pushes each visited cell onto a stack. When it hits a dead end with no unvisited neighbours, it pops back down the stack until it finds a cell that still has somewhere to go — that backtracking is what produces the long, winding corridors with exactly one path between any two points.

Once every cell has been visited, the maze is complete and the screensaver switches to solving it. It runs a breadth-first search from the top-left corner to the bottom-right, exploring outward through the open passages until it reaches the goal, then walks the chain of parents backward to recover the shortest route. That solution path is drawn in your accent color, tracing the way through.

The Speed control sets how many carving or solving steps happen per second, so you can watch the maze build slowly cell by cell or have it spring into existence. After the solve finishes, the path is held on screen for a couple of seconds, then the whole grid is rebuilt and the cycle starts over with a brand-new layout.

The Cell size control sets how fine the maze is — small cells pack in a dense, intricate labyrinth, while large cells give a coarse, easy-to-read maze. Turning Auto-solve off lets the maze simply finish carving and hold without tracing a solution. The accent Color and Background are both adjustable.

Depth-first mazes and the shape of a perfect maze

A maze with no loops and no sealed-off areas is often called a perfect maze, and it corresponds to a spanning tree of the grid: every cell is reachable, and there is exactly one route between any two cells. Maze generation is therefore commonly approached as generating a random spanning tree, a topic in graph theory.

Different generation algorithms leave different textures. Depth-first search, which follows a path until it is stuck before backing up, produces mazes with a low branching factor and many long corridors. Prim’s and Kruskal’s algorithms are biased toward many short dead ends instead. Wilson’s algorithm, built on loop-erased random walks, produces an unbiased sample from all possible mazes, so it has none of those biases.

Solving is the reverse exercise. Depth-first and breadth-first search are the standard approaches. Breadth-first search spreads outward evenly from the start and finds the shortest route; depth-first search may wander before arriving. In a perfect maze there is only one route between two cells, so any search that reaches the goal has found it.

A worked example

With the defaults — Cell size 18px, Speed 45, Auto-solve on, cyan accent (#6ee7ff) — the maze carves itself in a few seconds, a bright cursor leading the way, then a cyan line threads from the top-left to the bottom-right corner before the screen resets. For a denser labyrinth, drop Cell size to 8px; to slow the carving into something you can follow cell by cell, lower Speed toward 5.

Settings & tips

Frequently asked questions

Is the Maze screensaver free?
Yes. It runs free in your browser with no download or account. Open the page, let it fill the screen, and press ESC to exit.
What algorithm generates the maze?
It uses a recursive backtracker, a depth-first algorithm that carves passages from a starting cell and backtracks at dead ends. This produces a perfect maze with exactly one path between any two cells.
How does it solve the maze?
It runs a breadth-first search from the top-left corner to the bottom-right, then traces the shortest path back through the parents it recorded. That path is drawn in the accent color.
Does it make a new maze each time?
Yes. After the maze is carved and solved, the solution is held briefly, then the grid is rebuilt with a completely new random layout and the cycle repeats.
Can I make the maze bigger or smaller?
Yes. The Cell size control sets how large each maze cell is, so smaller cells create a denser, more intricate maze and larger cells create a coarser one.
What is a perfect maze?
It is a maze with exactly one path between any two cells, with no loops and no unreachable areas. In graph terms it is a spanning tree of the grid.
Why do depth-first mazes have long winding corridors?
The algorithm keeps extending the current path as long as it can, and only backtracks at a dead end. That gives a low branching factor and many long corridors, in contrast to Prim’s algorithm, which favours many short dead ends.

← All Generative screensavers