← All resources

mxgmn GitHub - Wave Function Collapse

Auto-discovered

Library / Codebase Intermediate

mxgmn

Visit resource ↗

Description

The mxgmn WaveFunctionCollapse repo is Maxim Gumin's reference C# Wave Function Collapse code. It synthesizes bitmaps or tilemaps locally similar to one example via overlapping and tiled models that learn small pixel patterns or adjacency rules.

Each run begins unobserved, collapses the lowest-entropy region using input weights, and propagates forbidden neighbors until the grid completes or contradicts. Only patterns present in the sample may appear in the output.

The README walks algorithm steps, tile symmetry, 3D voxel notes, constraints, and many language ports. Intermediate procedural-generation readers can build .NET source or try linked demos.

Model.cs illustrates entropy selection, banning, and propagation. Use it as an algorithm study, not a drop-in engine plugin.

Often cited in game-dev threads and linked from commercial uses such as Townscaper and Bad North.