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.

How does it 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

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.

Tileset:

Cells (NxN):

Step delay (ms):

Your browser does not support the HTML5 canvas tag.