📚 Encyclopedia

Games & Graphics · updated 2026-10-13

Wave function collapse for island terrain (and why it never contradicts)

wfcwave-function-collapseprocedural-generationterrainconstraint-solvinga-star

Wave function collapse (WFC) fills a grid by repeatedly picking the cell with the fewest remaining possibilities (minimum entropy), collapsing it to one tile, and propagating adjacency constraints to its neighbors. It is famous for hitting contradictions (a cell with zero options left). Archipelago, a single-file island generator (free-time build, post #1697, live at justinahampton.com/fun/freetime/archipelago/), measured when that happens.

The setup

The finding: chain rules cannot contradict

With chain adjacency, the set of allowed tiles for any cell is always a contiguous run of the chain. The constraint is connected-row-convex, a class of constraints for which local consistency (arc consistency, which WFC's propagation enforces) guarantees a solution exists. Result: 0 contradictions in 3 million collapses.

With non-convex rules (a ?hard mode where some non-adjacent tiles may touch and some adjacent ones may not), contradictions appeared in 44 percent of seeds. A local repair step (reset a small neighborhood around the contradiction and re-collapse it) fixed all of them, so a full restart is not needed.

Practical rule: if you can express your tileset as an ordered chain (or a tree with convex domains), WFC needs no backtracking. Add backtracking or local repair only when your rules break convexity.

Tooling worth copying

See also

Sources: home memory misc-side-projects (Archipelago, post #1697), justinahampton memory fun-freetime