4.1What is WFC?
Superposition, collapse, propagation and contradiction.

Wave Function Collapse (WFC) solves a grid the way people solve Sudoku: write down every possibility, fill in the most constrained cell, cross out what that rules out, repeat. Maxim Gumin published in 2016 and borrowed the name from quantum physics, but nothing in it is quantum. It is a constraint solver with a good story.
Four words carry the whole lesson:
| Word | Meaning in WFC | Meaning in Sudoku |
|---|---|---|
| Superposition | Every cell starts holding the full list of tiles it could become | Pencil all nine digits into every empty square |
| Collapse | Pick one undecided cell and fix it to a single tile | Write a digit in ink |
| Propagation | Remove every option in the neighbours that no longer fits, and keep spreading while anything changes | Cross the digit out of its row, column and box, then follow the knock-on effects |
| Contradiction | Some cell is left with no options at all | A square where no digit fits: rub it all out and start again |
Which cell to collapse next matters. WFC always picks the cell with the fewest options left, its lowest entropy. Deciding the most constrained cell first, while it still has a choice, keeps contradictions rare. Ties are broken at random, and that randomness is where the variety comes from.

The tiles never know about the whole design. Each tile only states what sits on each of its edges, called sockets: a pipe or nothing. Two tiles may touch when the sockets on their shared edge are equal.
A first exercise without a computer
Draw a 4 × 4 grid, pencil the six tile shapes into every cell, and run the algorithm by hand for five steps.
The algorithm step by step
After one set-up pass, the solver runs a three-step loop until every cell is decided or one runs out of options.
Two loops sit around that work. The inner loop runs once per collapse, about one per cell: find the lowest-entropy cell, collapse it, then propagate. The outer loop restarts the whole grid with a new seed, and is rare with a forgiving tile set. With Border on, the edge cells lose their outward-facing tiles straight after Superposition, and that change is propagated before the first Observe.
Propagate in plain words
Keep a stack of cells that just changed. Take one off. For each of its neighbours, collect every tile allowed next to any option still left in this cell, and keep only those in the neighbour. If the neighbour lost anything, push it on the stack, because its own neighbours may now be affected. Stop when the stack is empty, or report a contradiction the moment a cell runs out of options.
for each direction d:
allowed = union of rules[t][d] for every t still in Wave[i]
Wave[j] = Wave[j] ∩ allowed
if Wave[j] shrank: push j
if Wave[j] is empty: contradiction In 2D there are four directions. In 3D the same loop runs over six. The rule does not change.
Check yourself
Your answers stay in this browser.
What is a collapse?
Which cell does WFC collapse next?
When may two tiles touch?
What is a collapse?
Collapse writes one tile in ink. An empty cell is a contradiction, and the full list is superposition.
Which cell does WFC collapse next?
Lowest entropy first. Ties are broken at random, and that is where the variety comes from.
When may two tiles touch?
Each tile only states the label on each edge. Equal labels on the shared edge are the whole rule.
