Apex › Storage & databases

Generating maps by constraints (wave function collapse)

Fill a grid so every neighboring pair obeys adjacency rules. Each cell starts in superposition (any tile); repeatedly collapse the lowest-entropy cell (fewest options) to one random tile, then propagate — delete now-impossible tiles from neighbors, cascading outward (arc-consistency, like a Sudoku solver). When every cell holds one tile, the whole grid satisfies the rules by construction — no final check needed. Verified in node: 0 constraint violations across 2000 generated grids, contradictions ~0% with the min-entropy order, and varied output. The engine behind procedural game maps and textures. Step the collapse or generate a fresh map.

More in Storage & databases