# marian42/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/marian42-wavefunctioncollapse).**

4,847 stars · 546 forks · C# · MIT

## Links

- GitHub: https://github.com/marian42/wavefunctioncollapse
- Homepage: https://marian42.itch.io/wfc
- awesome-repositories: https://awesome-repositories.com/repository/marian42-wavefunctioncollapse.md

## Topics

`procjam` `unity` `wavefunctioncollapse`

## Description

This project is a wave function collapse generator and voxel environment engine used for procedural world generation. It implements a constraint-based layout algorithm to resolve superpositions of modules into consistent 3D voxel grids.

The system functions as a procedural city generator capable of creating infinite, walkable urban environments. It utilizes a dynamic dictionary to stream map data as a user approaches new areas, ensuring a continuous world without loading the entire layout at once.

The engine manages layout consistency through adjacency rule definitions, boundary constraint enforcement, and prototype-driven rule definitions. To ensure successful generation, it employs entropy-based module selection and a backtracking algorithm to resolve layout contradictions by undoing previous placement decisions.

An editor tool is included for initializing and inspecting generated areas through a map generation preview.

## Tags

### Game Development

- [Procedural World Generation](https://awesome-repositories.com/f/game-development/procedural-world-generation.md) — Creates infinite walkable urban environments and cities using procedural layout algorithms.
- [Voxel World Generation](https://awesome-repositories.com/f/game-development/simulation-engines/simulation-worlds/voxel-world-generation.md) — Implements a procedural engine for generating 3D block-based voxel grid environments using wave function collapse. ([source](https://marian42.de/article/wfc/))
- [Constraint-Based Layout Generation](https://awesome-repositories.com/f/game-development/constraint-based-layout-generation.md) — Defines connectivity rules and probabilities to automatically arrange 3D assets without manual placement.
- [Dynamic World Streaming](https://awesome-repositories.com/f/game-development/dynamic-world-streaming.md) — Employs a dynamic dictionary to stream and populate map slots as the user explores the world.
- [Voxel Engines](https://awesome-repositories.com/f/game-development/game-engines-frameworks/game-engines/voxel-engines.md) — Provides a voxel environment engine for building 3D worlds using modular components.
- [Level Design Tools](https://awesome-repositories.com/f/game-development/level-design-tools.md) — Designs game maps using predefined modules and adjacency rules to maintain visual consistency.
- [Module Generation Rules](https://awesome-repositories.com/f/game-development/module-generation-rules.md) — A configuration system for defining module spawn probabilities and connectivity constraints via prototype components. ([source](https://cdn.jsdelivr.net/gh/marian42/wavefunctioncollapse@master/README.md))
- [Procedural City Generators](https://awesome-repositories.com/f/game-development/procedural-city-generators.md) — Functions as a procedural city generator capable of creating infinite, walkable urban environments.
- [Urban Layout Generators](https://awesome-repositories.com/f/game-development/procedural-settlement-generators/urban-layout-generators.md) — Provides an infinite, walkable urban environment generator based on predefined architectural modules. ([source](https://cdn.jsdelivr.net/gh/marian42/wavefunctioncollapse@master/README.md))
- [Infinite Terrain Generators](https://awesome-repositories.com/f/game-development/tooling-asset-pipeline/procedural-generation/infinite-terrain-generators.md) — Generates infinite city layouts dynamically as the user moves to avoid loading the entire world.
- [Connector-Based Compatibility Rules](https://awesome-repositories.com/f/game-development/3d-game-engines/rapid-prototyping/data-driven-prefab-prototyping/connector-based-compatibility-rules.md) — Uses component metadata and connector numbers to determine compatible modules for layout.
- [Adjacency Rule Systems](https://awesome-repositories.com/f/game-development/adjacency-rule-systems.md) — Specifies compatible neighboring modules using connector identifiers and symmetry flags for consistency. ([source](https://marian42.de/article/wfc/))
- [Boundary Constraint Systems](https://awesome-repositories.com/f/game-development/boundary-constraint-systems.md) — Enforces specific connector types at environment boundaries to ensure seamless transitions. ([source](https://marian42.de/article/wfc/))
- [Procedural Layout Recovery](https://awesome-repositories.com/f/game-development/procedural-layout-recovery.md) — Ships a backtracking algorithm to resolve layout contradictions by undoing previous module placement decisions. ([source](https://marian42.de/article/wfc/))

### Part of an Awesome List

- [Superposition Voxel Grids](https://awesome-repositories.com/f/awesome-lists/ai/point-cloud-and-3d-processing/3d-point-cloud-representations/voxel-based-grids/superposition-voxel-grids.md) — Represents grid cells as superpositions of all possible modules until the wave function collapses.
- [Scripting and Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/scripting-and-utilities.md) — Procedural city generation.

### Software Engineering & Architecture

- [Backtracking Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/backtracking-algorithms.md) — Uses a backtracking algorithm to undo layout decisions when the generator reaches a contradiction.
- [Entropy-Based Solvers](https://awesome-repositories.com/f/software-engineering-architecture/entropy-based-solvers.md) — Selects the next cell to collapse based on the lowest entropy to minimize generation errors.
- [Wave Function Collapse Implementations](https://awesome-repositories.com/f/software-engineering-architecture/wave-function-collapse-implementations.md) — Implements a wave function collapse algorithm to resolve module superpositions into a 3D grid.
- [Constraint Propagation Engines](https://awesome-repositories.com/f/software-engineering-architecture/constraint-propagation-engines.md) — Implements a constraint propagation system to prune invalid module options in neighboring voxel cells.
