Wave-Function-Collapse

Straight out of quantum mechanics, Wave Function Collapse (WFC) is an algorithm for procedural generation of images. This repository features two approaches to the WFC: the Tiled Model (Coding Challenge 171) and the Overlapping Model (Coding Challenge #186). Both implementations are available in JavaScript (p5.js) and ported to Processing (Java).

GIF animation of the tiled WFC algorithm GIF animation of the overlapping WFC algorithm

Coding Challenges

Archived Raw Footage

Overview

Wave Function Collapse is a constraint-satisfaction algorithm inspired by quantum mechanics. At a high level, you have:

  1. Tiles (or “patterns”) that can appear in each cell.
  2. Adjacency rules describing which tiles can appear next to each other.
  3. Entropy that helps decide which cell to collapse (choose a tile for) next.
  4. Propagation to eliminate invalid tiles from neighbors as constraints tighten.

Completed

Corrections / Additional Features

Community Contributions and Improvements

Key Resources