Zødiac

Code & 3d Art

2D Wave Function Collapse

Python - PyGame

April 2022

We Made with Seb-lg a simple 2D python implementation of the well known Wave Function Collapse (WFC) algorithm using PyGame
Source code available here, and I also made a 3D version of it

Here are the final 89 modules obtained by adding the rotations from the 30 modules I drew


I also implemented different ways of choosing the state of the cell collapsing:

0) Random: randomly select a state from the possible states list

1) Override: if we can set the same state as the previous collapse, do it!

I added a max_consecutive_collapses stop to prevent the algorithm from overdoing it

2) Lowest: select the state which is the least seen amongst all collapsed cells

3) Meta-random: Choose one of those modes at random each time