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.