← Gallery

Wave Collapse

Every cell holds every tile at once, until picking one for the most constrained cell rules options out of its neighbours, and theirs.

Output

A set shares every setting — paper, border, the sketch’s own knobs — and differs only in the seed. Regenerate any one of them without touching the others.

PNG: 3508 × 4961 px at 300 dpi. PDF: vector, RGB, 297 × 420 mm page, no bleed. Printed area 297 × 420 mm.

0 mm

Millimetres of unprinted paper on every side. The piece is composed to fit what is left, not shrunk to fit it.

Grid

18

All three are the same tile set and the same solve — only the drawing differs.

Force the outside edge to carry nothing, so no line runs off the sheet.

Solver

The heart of it. Fewest-first keeps the difficult decisions early; scanline contradicts itself constantly and has to restart.

Tile weights

2.0

Set a weight to zero to take that tile out of the set entirely.

2.0
3.0
1.0
0.0

A stub that stops in the middle of its own cell. Lets a run end anywhere, which makes the grid far easier to satisfy.

Drawing

6.0

Colour

How it works

Wave function collapse borrowed its name from quantum mechanics and nothing else. Every cell of the grid starts holding all of the tiles at once, as a bitmask. The solver finds the cell with the fewest options left, picks one of them at random weighted by the tile weights, and then propagates: a fixed tile fixes the edge it presents to each neighbour, which rules options out there, which rules more out further along. Collapse, propagate, repeat, until every cell holds exactly one tile.

The only rule in the whole thing is that abutting edges must match — each tile carries four sockets, and a tile may sit east of another only if its west socket equals that one’s east. Nothing plans a route across the sheet. The long runs and the closed loops are what is left after the impossible has been removed, and the border closes because the outside is declared to carry nothing before the first collapse.

The collapse order is the part worth playing with, so it is a control. Fewest-options-first is the standard choice and it works because it keeps the difficult decisions early, while there is still room to satisfy them. Scanline order contradicts itself constantly: it commits to the easy top-left of the grid and then discovers the bottom-right cannot be finished. A contradiction — a cell with no legal tile at all — is answered here by starting the grid over, which is the cheap answer; the expensive answer is to backtrack.

R regenerate · S PNG · P PDF