After a short break, this week I’m exploring the Wave Function Collapse algorithm, following this video by The Coding Train.
What Is Wave Function Collapse #
According to Wikipedia:
[...] a family of constraint-solving algorithms commonly used in procedural generation, especially in the video game industry.
In simpler terms, it’s a system that generates patterns or terrains based on rules: it decides what can go where, making sure every new tile fits the constraints of its neighbors.
It’s often used in procedural world generation for games, where randomness needs to feel intentional.
How It Works #
The sketch creates a grid of cells across the canvas and assigns a tile to each one.
Every time a new tile is placed, it checks the constraints of its neighbors and narrows down the possible options. If more than one tile fits, it picks one at random while balancing order and chance.
What emerges is a patchwork of tiles that looks structured yet organic, as if the design grew naturally from a set of invisible rules.
Final Result #
Here’s the sketch in motion. Watch how the grid resolves itself into a coherent pattern.