I talk about this here on YouTube.
This project implements the wavefunction collapse algorithm in Rust. The algorithm generates tile-based patterns using local constraints, suitable for procedural content generation.
Tiles are loaded from the img directory as PNG files. The configuration for tile edges and weights is provided in config.json. The program outputs an animated GIF showing the collapse process.
To build and run the program with optimal performance, use:
cargo run --releaseThe output GIF will be written to output.gif in the project directory.
Dependencies include the image and gif crates. Ensure you have Rust and Cargo installed.
Example output:
└┘.┌--┘┌-┐.└-┘.└┐└┘|
..┌┘...└-+--┐...|..|
┐.└---┐..|┌┐└┐.┌+--┘
└-┐┌--┘┌-┘└┘.|.|└┐┌-
-┐└┘┌-┐└-┐┌--┘.└┐||.
-┘..|.|┌-┘|.┌┐..||└┐
..┌┐└┐||..└┐||..└┘┌┘
..└+-+┘|┌-┐|||.┌-┐|.
---┘.|.└+-++┘|┌┘.└┘.
┐...┌┘..|.||.||....┌
+┐..└--┐|┌+┘.└┘.┌┐┌┘
|└┐....└+┘|┌-┐..|||.
└-┘.....|.||.|..||└-
.┌-┐.┌┐┌+┐|└-┘┌┐└┘..
-+┐└┐|└┘└┘|..┌+┘...┌
.└+┐||....|┌-+┘....|
..||└+-┐.┌┘|.|..┌┐.└
--┘|.|.└-┘.└-┘.┌┘└--
...└┐|..┌--┐.┌┐|....
┌┐..└+--┘..|.└┘└-┐..
