Fill a grid so every neighbour is compatible, from a tiny set of rules — the trick behind endless game worlds that always look hand-made. Each cell starts as a superposition of all tiles; repeatedly collapse the most-constrained cell to one tile and propagate the consequences to its neighbours. It is constraint propagation — Sudoku solving — wearing a quantum costume. The grid is array work, so it runs in I-13.
Every cell holds the set of tiles it could still be (its “wave”). Pick the cell with the fewest options left (lowest entropy), collapse it to one legal tile, and remove now-illegal options from its neighbours; keep propagating until nothing changes, then repeat. Here: a coast rule — sea beside sea or shore, land beside land or shore. Watch it settle. live demo
“Wave Function Collapse, 2016” — a brilliant name on an idea that was invented then published nine years earlier under a plainer one. cited
The idea was Merrell’s; the name and the entropy heuristic were what made it spread. Merrell, 2007
WFC is a grid (a bounded array) of small possibility sets and a propagation loop — indexed reads and writes, comparisons, and the seeded PRNG for the collapse order (all landed):