I’ve been experimenting with Wave function collapse (WFC) algorithm when @sozap’s comment made me wonder if I could generate a world with it.
Kenney’s cute models and Roo Walker’s playful music inspired me to make this video.
Just a handful of tiles are placed manually, everything else is filled in procedurally.
The algorithm is pretty straightforward (here’s a great explanation using sudoku as an example):
- At the beginning every cell in grid can take any tile.
- Then some cell is selected and one of the tiles available for this cell is choosen.
- This choice affects cell’s neighbours (and neighbours of its neighbours).
- It repeats until all cells have tiles selected or it fails (no appropriate tile found for the cell).

The grid is 158x97x21 cells. It wasn’t generated in one go. Unfortunately, the bigger the grid the more likely the algorithm will fail. So you split the desired grid in blocks that overlap each other. In my case blocks are 10-18 cells long/wide and 3-6 high.
The video does not show the generation sequence for artistic purposes. Here’s how it actually looks like.

There are 516 tiles (including rotations and mirroring) + 338 substitutes (used after the grid is generated).
The adjacency rules are calculated partially automatically (it is a number representing unique geometry+color of tile’s side).
There are sets of tiles that can only connect to each other.
One of the annoying generation issues was rivers going up and down. Adding inflow/outflow connection rule instead of just river solved the issue.
Other frustrating thing was houses tightly packed together. By adding orientation connection rule to fundament tile facades are no longer placed next to walls.
What I would’ve done differently is making roads and rivers with some other algorithm and filling the rest with WFC (to fix loops and disconnected roads).
Near the end of the project I decided to try new list data type (CGMatter and Cartesian Caramel videos were very helpful).
To compare apples to apples, I updated my point-based implementation. Interestingly, points and lists gave me the same performance, but were way faster then the previous one.
The most time consuming part was tuning tile weights for specific outcome, it is pretty hard to control.
Exploring this place is fascinating.
The question is - what’s my input in this project? I haven’t designed models, I haven’t invented the algorithm, the output although highly influenced by me is still generated and I don’t like the slot machine aspect of it. What I do like is making things with geometry nodes and it was a nice exercise.
Other useful resources in case someone would also like to learn about WFC:











