Interactive demo

Wave Function Collapse

Wave Function Collapse (WFC) is a constraint-based procedural generation algorithm: given a set of tiles and rules that describe which tiles can touch, it generates a valid grid by repeatedly picking the most constrained cell and propagating the consequences.

Your browser does not support the HTML5 canvas tag.

Tip: click one of the small tiles inside an undecided cell to decide that cell yourself.

Grid

Playback

Display

How does wave function collapse work?

Each grid cell starts in a “superposition” of possible tiles. The solver collapses one cell (usually with the lowest entropy / fewest options), then removes incompatible options from its neighbors. This constraint propagation continues until the grid is solved, or the solver backtracks and tries a different choice.

Credits and background

This demo is based on the Wave Function Collapse algorithm popularized by Maxim Gumin (mxgmn) (see WaveFunctionCollapse) and is inspired by Paul Merrell’s work on model synthesis.