Skip to main content

Wave function collapse

Sudoku with stitches

In plain words

The computer first cuts every original chart into tiny overlapping squares, for example 3 stitches by 3, and remembers which squares can sit next to which. Then it treats the empty gap between two motifs like a Sudoku: every empty stitch could still be anything, and each decision rules out options for its neighbours.

It always fills the stitch with the fewest options left, picks one of the squares that still fit (common squares more often), and passes the consequences on to the neighbours. If it paints itself into a corner it starts that gap again with the next seed.

Every little square in the result really occurs in Sjónabók, but nothing forces the bigger picture to make sense, so the fill can look scattered.

The setting

Window size. A 2×2 window gives the computer very few rules, so the fill is close to random noise. A 3×3 window keeps more of the book’s local shapes. Larger windows look more like the book, but they were too slow in the Python prototype; that is a job for the C++ version.

The banner

Good at, weak at

Good at Weak at
Every small patch is authentic Sparse and fragmented between motifs
Motifs are easy to pin in place No sense of overall composition

Sources

The papers behind this page. Where a free copy exists (author page, arXiv, university repository), the link goes there.

Gumin, Maxim. 2016. WaveFunctionCollapse. Software repository, GitHub. https://github.com/mxgmn/WaveFunctionCollapse.
Karth, Isaac, and Adam M. Smith. 2017. “WaveFunctionCollapse Is Constraint Solving in the Wild.” Proceedings of the 12th International Conference on the Foundations of Digital Games (FDG). https://doi.org/10.1145/3102071.3110566.
Karth, Isaac, and Adam M. Smith. 2022. “WaveFunctionCollapse: Content Generation via Constraint Solving and Machine Learning.” IEEE Transactions on Games. https://escholarship.org/uc/item/3rm1w0mn.
Merrell, Paul. 2007. “Example-Based Model Synthesis.” Proceedings of the 2007 Symposium on Interactive 3D Graphics and Games (I3D), 105–12. https://doi.org/10.1145/1230100.1230119.
Merrell, Paul. 2021. Comparing Model Synthesis and Wave Function Collapse. https://paulmerrell.org/wp-content/uploads/2021/07/comparison.pdf.
Merrell, Paul, and Dinesh Manocha. 2011. “Model Synthesis: A General Procedural Modeling Algorithm.” IEEE Transactions on Visualization and Computer Graphics 17 (6): 715–28. https://www.cs.princeton.edu/courses/archive/spring11/cos598A/pdfs/Merrell10b.pdf.

Background reading: Model synthesis (Wikipedia) · Constraint programming (Wikipedia)