
3d wave function collapse
An implementation of the Wave Function Collapse algorithm to generate cityscapes in 3D.
​
This algorithm works with a grid of cells that contain all possible states of a cell. Iterating through the cells, one cell at a time gets their state assigned and their possible states reduced to one. This change reduces the amount of states a neighbouring cell can have. Like a wave running through the grid, possibilities get reduced and cells get collapsed, until eventually the whole grid is collapsed.

2D to 3D
To better understand the algorithm I first created a 2D prototype in Processing. The difference in complexity the third layer brought was quite unexpected.

Iteration
Working through one axis at a time, after many bugs and subsequent bugfixes the algorithm worked.

visualisation
With a more visually appealing tileset and some controls, a demo is now available that allows anyone to generate a simple cityscape with this algorithm.