# ijdykeman/wangtiles architecture

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

- Interactive diagram: https://gitdiagram.com/ijdykeman/wangtiles
- Repository: https://github.com/ijdykeman/wangtiles

## Overview

This repository is a collection of Wang-tile procedural-generation experiments. The documented workflow defines colored tiles, arranges them with matching edges and randomized choices, and produces map-like images. The sampled 3D modules expose edge potentials and display helpers, while the read Gibbs samplers reference tile extraction and sphere-generation modules. The exact runtime calls between these stages are not shown, so those links are marked unverified; the unrelated voxel editor and vendored dependencies are omitted.

Main entry points: [`experimental_code/tiles_3d/sphere_gibbs.py`](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/sphere_gibbs.py) (Sphere Gibbs), [`experimental_code/tiles_3d`](https://github.com/ijdykeman/wangtiles/tree/master/experimental_code/tiles_3d) (3D Tile Extraction), [`experimental_code/tiles_3d/potentials.py`](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/potentials.py) (Edge Potentials), [`experimental_code/tileset_generation/main.py`](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tileset_generation/main.py) (Generation Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tile_inputs["Tile Inputs"]
  node_tile_extract["Tile Extraction<br/>[extract_tiles.py]"]
  node_tile3d_extract["3D Tile Extraction"]
  node_tile_properties["Tile Properties<br/>[tile_properties.py]"]
end

subgraph group_constraints["Matching Constraints"]
  node_potentials["Edge Potentials<br/>[potentials.py]"]
  node_solver["CSP Solver<br/>[csp_solver.py]"]
end

subgraph group_generation["World Generation"]
  node_gibbs2d["Grid Gibbs"]
  node_sphere["Sphere Geometry<br/>[create_sphere.py]"]
  node_sphere_gibbs["Sphere Gibbs<br/>[sphere_gibbs.py]"]
  node_generation_entry["Generation Entry<br/>[main.py]"]
end

subgraph group_presentation["Presentation"]
  node_display["World Display<br/>[display.py]"]
  node_tileset_output["Tileset Output"]
end

node_user(("Tile Author"))

node_user -.->|"defines tiles"| node_tile_extract
node_user -.->|"defines tiles"| node_tile3d_extract
node_tile_extract -.->|"supplies tiles"| node_solver
node_tile3d_extract -.->|"supplies tiles"| node_potentials
node_tile_properties -.->|"describes tiles"| node_potentials
node_potentials -.->|"constrains sampling"| node_sphere_gibbs
node_sphere -.->|"defines geometry"| node_sphere_gibbs
node_tile3d_extract -->|"provides tiles"| node_sphere_gibbs
node_sphere_gibbs -.->|"renders result"| node_display
node_generation_entry -->|"uses properties"| node_tile_properties
node_generation_entry -.->|"writes tileset"| node_tileset_output

click node_tile_extract "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/ascii_tiles/extract_tiles.py"
click node_tile3d_extract "https://github.com/ijdykeman/wangtiles/tree/master/experimental_code/tiles_3d"
click node_tile_properties "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/tile_properties.py"
click node_potentials "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/potentials.py"
click node_solver "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/ascii_tiles/csp_solver.py"
click node_gibbs2d "https://github.com/ijdykeman/wangtiles/tree/master/experimental_code/tiles_3d"
click node_sphere "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/create_sphere.py"
click node_sphere_gibbs "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/sphere_gibbs.py"
click node_generation_entry "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tileset_generation/main.py"
click node_display "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/display.py"
click node_tileset_output "https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/output_tileset_vox.py"

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_tile_extract,node_tile3d_extract,node_tile_properties toneBlue
class node_potentials,node_solver toneAmber
class node_gibbs2d,node_sphere,node_sphere_gibbs,node_generation_entry toneMint
class node_display,node_tileset_output toneRose
class node_user toneIndigo
```

## Components

### Tile Inputs

- [Tile Extraction](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/ascii_tiles/extract_tiles.py): `experimental_code/ascii_tiles/extract_tiles.py`
- [3D Tile Extraction](https://github.com/ijdykeman/wangtiles/tree/master/experimental_code/tiles_3d): `experimental_code/tiles_3d`
- [Tile Properties](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/tile_properties.py): `experimental_code/tiles_3d/tile_properties.py`

### Matching Constraints

- [Edge Potentials](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/potentials.py): `experimental_code/tiles_3d/potentials.py`
- [CSP Solver](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/ascii_tiles/csp_solver.py): `experimental_code/ascii_tiles/csp_solver.py`

### World Generation

- [Grid Gibbs](https://github.com/ijdykeman/wangtiles/tree/master/experimental_code/tiles_3d): `experimental_code/tiles_3d`
- [Sphere Geometry](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/create_sphere.py): `experimental_code/tiles_3d/create_sphere.py`
- [Sphere Gibbs](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/sphere_gibbs.py): `experimental_code/tiles_3d/sphere_gibbs.py`
- [Generation Entry](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tileset_generation/main.py): `experimental_code/tileset_generation/main.py`

### Presentation

- [World Display](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/display.py): `experimental_code/tiles_3d/display.py`
- [Tileset Output](https://github.com/ijdykeman/wangtiles/blob/master/experimental_code/tiles_3d/output_tileset_vox.py): `experimental_code/tiles_3d/output_tileset_vox.py`

### Other components

- **Tile Author**

## Connections

- Tile Author → Tile Extraction: defines tiles
- Tile Author → 3D Tile Extraction: defines tiles
- Tile Extraction → CSP Solver: supplies tiles (evidence: `experimental_code/ascii_tiles/csp_solver.py`)
- 3D Tile Extraction → Edge Potentials: supplies tiles (evidence: `experimental_code/tiles_3d/create_sphere.py`)
- Tile Properties → Edge Potentials: describes tiles
- Edge Potentials → Sphere Gibbs: constrains sampling
- Sphere Geometry → Sphere Gibbs: defines geometry
- 3D Tile Extraction → Sphere Gibbs: provides tiles
- Sphere Gibbs → World Display: renders result
- Generation Entry → Tile Properties: uses properties (evidence: `experimental_code/tileset_generation/main.py`)
- Generation Entry → Tileset Output: writes tileset
