explaingit

mxgmn/wavefunctioncollapse

25,059C#Audience · developerComplexity · 3/5MaintainedSetup · moderate

TLDR

An algorithm that generates new images or tile maps by learning patterns from a single example, creating infinite varied content that feels hand-crafted.

Mindmap

mindmap
  root((repo))
    What it does
      Learns from example
      Generates new images
      Creates tile maps
    How it works
      Picks constraints
      Locks in patterns
      Fills output
    Use cases
      Game level design
      Procedural dungeons
      Landscape generation
    Tech stack
      C# original
      Multi-engine ports
      Pixel art support
    Audience
      Game developers
      Indie creators
      Level designers

Things people build with this

USE CASE 1

Generate procedural game levels and dungeons that feel hand-crafted by learning from a single example tileset.

USE CASE 2

Create infinite landscape variations for open-world games while maintaining visual consistency with your art style.

USE CASE 3

Build texture generators that produce new patterns matching the local structure of an input image.

USE CASE 4

Design level editors that suggest new room layouts based on patterns from existing hand-made levels.

Tech stack

C#C++PythonJavaScriptUnityUnreal Engine 5Godot 4

Getting it running

Difficulty · moderate Time to first run · 30min

Requires choosing and setting up one of multiple engine integrations (Unity/Unreal/Godot) plus C++/C# compilation.

License could not be detected automatically. Check the repository's LICENSE file before use.

In plain English

Wave Function Collapse (WFC) is an algorithm that generates new images or tile maps by learning patterns from a single example image you provide. Think of it like this: you give it a small sample texture or tile set, and it creates a larger, new image that looks locally consistent with the original, same kinds of patterns appear in similar proportions, and neighboring tiles fit together the same way they did in the example. The name is borrowed from quantum mechanics (where "wave function collapse" describes a particle settling into a definite state), but the math here is simpler. The algorithm starts with every pixel or tile in "unknown" state, then repeatedly picks the most constrained spot, locks it in based on the patterns learned from your input, and ripples that decision outward. It keeps doing this until the whole output is filled in, or hits a contradiction and restarts. Game developers use WFC to generate levels, dungeons, and landscapes procedurally, meaning by algorithm rather than hand-crafting each one. It's been used in published games like Bad North, Caves of Qud, and Townscaper. You'd reach for it when you need infinite, varied content that still feels cohesive and hand-crafted in style. It works on pixel art bitmaps and tile-based maps, and has been ported to C++, Python, JavaScript, Unity, Unreal Engine 5, Godot 4, and more. The original implementation is written in C#.

Copy-paste prompts

Prompt 1
How do I use Wave Function Collapse to generate a dungeon level from a single example map in my game?
Prompt 2
Show me how to implement Wave Function Collapse in Python to generate textures from a sample image.
Prompt 3
What's the simplest way to integrate Wave Function Collapse into a Unity game for procedural level generation?
Prompt 4
Explain the constraint-propagation step in Wave Function Collapse and why it matters for avoiding contradictions.
Prompt 5
How do I port a Wave Function Collapse implementation from C# to my game engine?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.