Elwqnn/wfc

Implementation of the Wave Function Collapse algorithm, distributed as a reusable library

22

stars

28

commits

Rust

primary language

Mar 20, 2026

updated

README

Wave Function Collapse (WFC)

Wave Function Collapse overlapping model implementation in Rust. Generates novel images by extracting NxN patterns from samples and synthesizing outputs that follow the same adjacency constraints.

Algorithm

The overlapping model extracts all NxN pattern tiles from a sample image and records which patterns can appear adjacent to each other. Starting from a completely undetermined output, it iteratively:

  1. Finds the cell with lowest entropy (fewest possible patterns)
  2. Collapses it to a random valid pattern
  3. Propagates constraints to neighboring cells
  4. Repeats until complete or a contradiction occurs

GUI

cargo run --release --bin wfc-egui

WFC GUI Screenshot

Results

Edge Constraints

Let's see how edge constraints affect the output.

Sample:

Without constraintsVertical constraintsVertical + Sides constraints

License

MIT

Contributors

elwqnn

28 commits

Elwqnn/wfc

Implementation of the Wave Function Collapse algorithm, distributed as a reusable library

22

stars

28

commits

Rust

primary language

Mar 20, 2026

updated

README

Wave Function Collapse (WFC)

Wave Function Collapse overlapping model implementation in Rust. Generates novel images by extracting NxN patterns from samples and synthesizing outputs that follow the same adjacency constraints.

Algorithm

The overlapping model extracts all NxN pattern tiles from a sample image and records which patterns can appear adjacent to each other. Starting from a completely undetermined output, it iteratively:

  1. Finds the cell with lowest entropy (fewest possible patterns)
  2. Collapses it to a random valid pattern
  3. Propagates constraints to neighboring cells
  4. Repeats until complete or a contradiction occurs

GUI

cargo run --release --bin wfc-egui

WFC GUI Screenshot

Results

Edge Constraints

Let's see how edge constraints affect the output.

Sample:

Without constraintsVertical constraintsVertical + Sides constraints

License

MIT

Contributors

elwqnn

28 commits

Languages

Rust

97.8%

Just

1.4%