Wave Function Collapse Maze Screensaver
The Wave Function Collapse Maze screensaver runs a real constraint-solving tile generation algorithm live, the same technique used in modern procedural game generation. It is free, runs in your browser, and ESC exits.
How the Wave Function Collapse Maze screensaver works
The saver fills a grid one tile at a time, always picking the most constrained open cell next, exactly like the real wave-function-collapse algorithm.
Each placed tile must match its already-placed neighbors' edges, building a coherent connected maze-like pattern.
Once the grid completely fills, it fades and a fresh generation run begins.
This is the same real constraint-solving approach used in modern procedural game-level generation.
Wave function collapse: a name borrowed from physics
Wave function collapse (WFC) is a procedural generation method published on GitHub by Maxim Gumin (mxgmn). Despite the name it is not quantum mechanics: the author says it does not do the actual quantum mechanics, because its coefficients are real numbers rather than complex ones. The name is a metaphor. Every cell starts in a superposition, meaning it could still become any tile, and observing a cell collapses it to one.
The loop is simple. Find the cell with the lowest entropy, meaning the fewest remaining possibilities, pick one of its allowed states, then propagate the consequences: each neighbour must discard tiles whose edges no longer fit, which may in turn constrain their neighbours. This resembles constraint propagation in puzzle solvers, and it is why the output stays coherent without being planned in advance.
If propagation leaves a cell with no legal option, that is a contradiction and the run cannot continue; the project notes this happens surprisingly rarely in practice. The original technique can also learn from an example bitmap, constraining the output to contain only patterns found in the input; the simple tiled variant used for mazes just states which edges may touch. Games including Bad North and Caves of Qud have used WFC-style generation.
A worked example
A corridor tile snaps into place only where it correctly connects to its already-placed neighbors, gradually resolving into a coherent maze-like layout.
Settings & tips
- Accent recolours the tile edges.
- Based on the real wave-function-collapse algorithm used in game development.
- Each generation run produces a genuinely different layout.
Frequently asked questions
- Is this a real algorithm?
- Yes — the real wave-function-collapse constraint-solving algorithm, used in modern procedural generation.
- Is a key needed?
- No — it is a pure local computation.
- Is it free?
- Yes — free, no download, in your browser.
- Does the layout repeat?
- No — each generation run resolves a genuinely different layout.
- Why is it called wave function collapse if it is not physics?
- Each cell starts as a superposition of possible states and resolves to one when observed, like a quantum collapse. The author notes the algorithm does not do real quantum mechanics, since its coefficients are real numbers, not complex ones.
- What happens if the generator reaches a contradiction?
- A contradiction means some cell has no legal tile left. Implementations typically backtrack or restart the attempt.
- Why pick the most constrained cell first?
- WFC always observes the cell with the lowest entropy, the fewest remaining options. Resolving it first surfaces dead ends while choices are still few.