# mxgmn/WaveFunctionCollapse

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mxgmn-wavefunctioncollapse).**

24,697 stars · 1,319 forks · C# · other

## Links

- GitHub: https://github.com/mxgmn/WaveFunctionCollapse
- awesome-repositories: https://awesome-repositories.com/repository/mxgmn-wavefunctioncollapse.md

## Topics

`algorithm` `csharp` `gamedev` `machine-learning` `procedural-generation` `wfc`

## Description

WaveFunctionCollapse is a procedural generation engine that creates complex, non-repeating patterns by treating spatial arrangement as a constraint satisfaction problem. It functions as a stochastic solver that derives output structures from a single input example, ensuring that every element placed within a grid satisfies specific adjacency requirements relative to its neighbors.

The system distinguishes itself by using an entropy-driven approach to grid collapse, where it iteratively selects the cell with the fewest remaining possibilities to trigger a cascade of logical updates. By decomposing input data into local adjacency rules, the engine can synthesize coherent textures or construct structured game environments that maintain visual and logical consistency. When the algorithm encounters a contradiction, it employs a backtracking search mechanism to revert to previous states and explore alternative configurations.

This tool supports both pixel-based texture synthesis and modular tile-based layout generation. It manages the state of the grid through continuous propagation of constraints, ensuring that all generated content adheres to the patterns observed in the source sample.

## Tags

### Scientific & Mathematical Computing

- [Procedural Generation Engines](https://awesome-repositories.com/f/scientific-mathematical-computing/procedural-generation-engines.md) — A procedural generation engine that creates complex patterns by iteratively resolving local adjacency rules across a grid until a consistent state emerges.
- [Probabilistic Solvers](https://awesome-repositories.com/f/scientific-mathematical-computing/probabilistic-solvers.md) — A probabilistic algorithm that derives output structures from input examples by treating generation as a constraint satisfaction problem with local dependencies.
- [Tiling Systems](https://awesome-repositories.com/f/scientific-mathematical-computing/tiling-systems.md) — A grid-based layout tool that constructs coherent two-dimensional arrangements by matching edge constraints between a predefined set of modular tiles.

### Software Engineering & Architecture

- [Constraint-Based Synthesis Engines](https://awesome-repositories.com/f/software-engineering-architecture/constraint-based-synthesis-engines.md) — Solving complex spatial arrangement problems by ensuring every element placed in a grid satisfies specific adjacency requirements with its neighbors.
- [Procedural Content Generation](https://awesome-repositories.com/f/software-engineering-architecture/procedural-content-generation.md) — Creates complex, non-repeating game levels or textures automatically by following logical rules.
- [Entropy-Based Solvers](https://awesome-repositories.com/f/software-engineering-architecture/entropy-based-solvers.md) — The algorithm selects the cell with the fewest remaining possibilities and forces a choice to trigger a cascade of logical updates.
- [Constraint Propagation Engines](https://awesome-repositories.com/f/software-engineering-architecture/constraint-propagation-engines.md) — The system maintains a grid of possible states and iteratively prunes invalid options by propagating local adjacency rules across the entire field.
- [Backtracking Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/backtracking-algorithms.md) — The solver explores potential configurations by reverting to previous states whenever a local choice leads to a logical contradiction or dead end.
- [Constraint Satisfaction Solvers](https://awesome-repositories.com/f/software-engineering-architecture/constraint-satisfaction-solvers.md) — Decomposes input data into local constraints that dictate valid side-by-side tile placements.

### Game Development

- [Procedural Level Generators](https://awesome-repositories.com/f/game-development/procedural-level-generators.md) — Generates diverse and coherent game environments that maintain structural integrity.

### Artificial Intelligence & ML

- [Example-Based Synthesis](https://awesome-repositories.com/f/artificial-intelligence-ml/example-based-synthesis.md) — Creates complex visual patterns by iteratively collapsing grids based on adjacency constraints from input examples. ([source](https://github.com/mxgmn/WaveFunctionCollapse#readme))

### User Interface & Experience

- [Tiled Pattern Generators](https://awesome-repositories.com/f/user-interface-experience/tiled-pattern-generators.md) — Constructs two-dimensional grid patterns by placing tiles according to local adjacency rules. ([source](https://github.com/mxgmn/WaveFunctionCollapse/blob/master/SimpleTiledModel.cs))

### Graphics & Multimedia

- [Texture Synthesis](https://awesome-repositories.com/f/graphics-multimedia/texture-synthesis.md) — Produces large, seamless, and visually consistent patterns by replicating local pixel relationships.
