# mxgmn/wavefunctioncollapse architecture

> Architecture diagram of the GitHub repository mxgmn/wavefunctioncollapse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mxgmn/wavefunctioncollapse
- Repository: https://github.com/mxgmn/wavefunctioncollapse

## Overview

WaveFunctionCollapse is a command-line generator for locally similar bitmap and tilemap outputs. The workflow starts with generation settings, loads either a sample image or tile rules, builds pattern or adjacency constraints, then repeatedly observes and propagates constraints before saving a bitmap (and optionally tile text). The shared model owns the generation loop; the two model implementations prepare their distinct inputs and render results. The README describes rotations/reflections and the observation-propagation algorithm. The graph is based on the shown source and README; configuration and asset contents were not inspected.

Main entry points: [`Program.cs`](https://github.com/mxgmn/wavefunctioncollapse/blob/master/Program.cs) (CLI runner), [`OverlappingModel.cs`](https://github.com/mxgmn/wavefunctioncollapse/blob/master/OverlappingModel.cs) (Overlapping model), [`SimpleTiledModel.cs`](https://github.com/mxgmn/wavefunctioncollapse/blob/master/SimpleTiledModel.cs) (Simple tiled model), [`Model.cs`](https://github.com/mxgmn/wavefunctioncollapse/blob/master/Model.cs) (WFC engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Generation entry"]
  node_runner["CLI runner<br/>[Program.cs]"]
end

subgraph group_models["Generation models"]
  node_engine["WFC engine<br/>[Model.cs]"]
  node_overlap["Overlapping model"]
  node_tiled["Simple tiled model"]
end

subgraph group_io["Input and output"]
  node_settings["Run settings<br/>[samples.xml]"]
  node_sample["Sample images"]
  node_tiledata["Tile definitions"]
  node_bitmap["Bitmap I/O<br/>[Helper.cs]"]
  node_outputs["Generated files"]
end

node_user(("User"))

node_user -->|"runs"| node_runner
node_runner -->|"loads settings"| node_settings
node_runner -->|"constructs"| node_overlap
node_runner -->|"constructs"| node_tiled
node_overlap -->|"extends"| node_engine
node_tiled -->|"extends"| node_engine
node_overlap -->|"loads sample"| node_sample
node_overlap -->|"loads and saves"| node_bitmap
node_tiled -->|"loads definitions"| node_tiledata
node_tiled -->|"loads and saves"| node_bitmap
node_runner -->|"runs model"| node_engine
node_runner -->|"saves results"| node_outputs
node_engine -.->|"renders via model"| node_outputs

click node_runner "https://github.com/mxgmn/wavefunctioncollapse/blob/master/Program.cs"
click node_settings "https://github.com/mxgmn/wavefunctioncollapse/blob/master/samples.xml"
click node_engine "https://github.com/mxgmn/wavefunctioncollapse/blob/master/Model.cs"
click node_overlap "https://github.com/mxgmn/wavefunctioncollapse/blob/master/OverlappingModel.cs"
click node_tiled "https://github.com/mxgmn/wavefunctioncollapse/blob/master/SimpleTiledModel.cs"
click node_sample "https://github.com/mxgmn/wavefunctioncollapse/tree/master/samples"
click node_tiledata "https://github.com/mxgmn/wavefunctioncollapse/tree/master/tilesets"
click node_bitmap "https://github.com/mxgmn/wavefunctioncollapse/blob/master/Helper.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_user toneBlue
class node_engine,node_overlap,node_tiled toneAmber
class node_settings,node_sample,node_tiledata,node_bitmap,node_outputs toneMint
```

## Components

### Generation entry

- [CLI runner](https://github.com/mxgmn/wavefunctioncollapse/blob/master/Program.cs): `Program.cs`

### Generation models

- [WFC engine](https://github.com/mxgmn/wavefunctioncollapse/blob/master/Model.cs): `Model.cs`
- [Overlapping model](https://github.com/mxgmn/wavefunctioncollapse/blob/master/OverlappingModel.cs): `OverlappingModel.cs`
- [Simple tiled model](https://github.com/mxgmn/wavefunctioncollapse/blob/master/SimpleTiledModel.cs): `SimpleTiledModel.cs`

### Input and output

- [Run settings](https://github.com/mxgmn/wavefunctioncollapse/blob/master/samples.xml): `samples.xml`
- [Sample images](https://github.com/mxgmn/wavefunctioncollapse/tree/master/samples): `samples`
- [Tile definitions](https://github.com/mxgmn/wavefunctioncollapse/tree/master/tilesets): `tilesets`
- [Bitmap I/O](https://github.com/mxgmn/wavefunctioncollapse/blob/master/Helper.cs): `Helper.cs`
- **Generated files**

### Other components

- **User**

## Connections

- User → CLI runner: runs (evidence: `README.md`)
- CLI runner → Run settings: loads settings (evidence: `Program.cs`)
- CLI runner → Overlapping model: constructs (evidence: `Program.cs`)
- CLI runner → Simple tiled model: constructs (evidence: `Program.cs`)
- Overlapping model → WFC engine: extends (evidence: `OverlappingModel.cs`)
- Simple tiled model → WFC engine: extends (evidence: `SimpleTiledModel.cs`)
- Overlapping model → Sample images: loads sample (evidence: `OverlappingModel.cs`)
- Overlapping model → Bitmap I/O: loads and saves (evidence: `OverlappingModel.cs`)
- Simple tiled model → Tile definitions: loads definitions (evidence: `SimpleTiledModel.cs`)
- Simple tiled model → Bitmap I/O: loads and saves (evidence: `SimpleTiledModel.cs`)
- CLI runner → WFC engine: runs model (evidence: `Program.cs`)
- CLI runner → Generated files: saves results (evidence: `Program.cs`)
- WFC engine → Generated files: renders via model
