# glebdot/cellularautomata architecture

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

- Interactive diagram: https://gitdiagram.com/glebdot/cellularautomata
- Repository: https://github.com/glebdot/cellularautomata

## Overview

This is an interactive cellular-automata sandbox: users select a material and brush size, paint cells, and watch four material behaviors evolve on a grid. The main loop in `Application` connects configuration loading, painting, simulation steps, and rendering. The grid schedules active cells through a deduplicating FIFO queue; cell rules mutate the grid through swaps. The README also describes the four matter types and their interactions. Wiring is based on the sampled application, parser, grid, and cell sources; no additional unsampled runtime subsystems are inferred.

Main entry points: [`CellularAutomata/core/CellGrid.cpp`](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CellGrid.cpp) (Cell grid), [`CellularAutomata/Application.cpp`](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp) (Application loop), [`CellularAutomata/input/Parser.cpp`](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/input/Parser.cpp) (Config parser), [`CellularAutomata/core/Cell.cpp`](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/Cell.cpp) (Matter rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Interactive application"]
  node_main["Program entry"]
  node_app["Application loop<br/>[Application.cpp]"]
  node_painting["Material brush<br/>[Application.cpp]"]
  node_render["Grid and HUD<br/>[Application.cpp]"]
end

subgraph group_simulation["Simulation engine"]
  node_traits["Matter traits<br/>[Cell.h]"]
  node_grid["Cell grid<br/>[CellGrid.cpp]"]
  node_defaults[("Cell defaults<br/>[CellGrid.cpp]")]
  node_rules["Matter rules<br/>[Cell.cpp]"]
  node_scheduler["Update scheduler<br/>[UniqueQueue.h]"]
  node_types["Matter type mapping<br/>[CoreTypes.cpp]"]
end

subgraph group_configuration["Matter configuration"]
  node_parser["Config parser<br/>[Parser.cpp]"]
  node_config["Matter settings<br/>[config.txt]"]
end

node_user(("Player"))
node_window["SFML window"]

node_user -->|"interacts"| node_window
node_main -->|"starts"| node_app
node_app -->|"parses settings"| node_parser
node_parser -->|"reads"| node_config
node_parser -->|"maps type"| node_types
node_parser -->|"produces"| node_traits
node_app -->|"initializes and loads"| node_grid
node_grid -->|"builds defaults"| node_defaults
node_grid -->|"uses traits"| node_traits
node_painting -->|"creates cells"| node_grid
node_app -->|"handles input"| node_painting
node_app -->|"steps simulation"| node_grid
node_grid -->|"queues updates"| node_scheduler
node_grid -->|"dispatches steps"| node_rules
node_rules -->|"checks and swaps"| node_grid
node_render -->|"reads cells"| node_grid
node_render -->|"reads selected matter"| node_defaults
node_app -->|"draws frame"| node_render
node_app -->|"polls and displays"| node_window
node_window -->|"events and input"| node_app

click node_main "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/CellularAutomata.cpp"
click node_app "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp"
click node_painting "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp"
click node_render "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp"
click node_parser "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/input/Parser.cpp"
click node_config "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/config.txt"
click node_traits "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/Cell.h"
click node_grid "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CellGrid.cpp"
click node_defaults "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CellGrid.cpp"
click node_rules "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/Cell.cpp"
click node_scheduler "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/utils/UniqueQueue.h"
click node_types "https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CoreTypes.cpp"

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_main,node_app,node_painting,node_render toneBlue
class node_traits,node_grid,node_defaults,node_rules,node_scheduler,node_types toneAmber
class node_parser,node_config toneMint
class node_user,node_window toneIndigo
```

## Components

### Interactive application

- [Program entry](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/CellularAutomata.cpp): `CellularAutomata/CellularAutomata.cpp`
- [Application loop](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp): `CellularAutomata/Application.cpp`
- [Material brush](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp): `CellularAutomata/Application.cpp`
- [Grid and HUD](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/Application.cpp): `CellularAutomata/Application.cpp`

### Simulation engine

- [Matter traits](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/Cell.h): `CellularAutomata/core/Cell.h`
- [Cell grid](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CellGrid.cpp): `CellularAutomata/core/CellGrid.cpp`
- [Cell defaults](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CellGrid.cpp): `CellularAutomata/core/CellGrid.cpp`
- [Matter rules](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/Cell.cpp): `CellularAutomata/core/Cell.cpp`
- [Update scheduler](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/utils/UniqueQueue.h): `CellularAutomata/utils/UniqueQueue.h`
- [Matter type mapping](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/core/CoreTypes.cpp): `CellularAutomata/core/CoreTypes.cpp`

### Matter configuration

- [Config parser](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/input/Parser.cpp): `CellularAutomata/input/Parser.cpp`
- [Matter settings](https://github.com/glebdot/cellularautomata/blob/master/CellularAutomata/config.txt): `CellularAutomata/config.txt`

### Other components

- **Player**
- **SFML window**

## Connections

- Player → SFML window: interacts
- Program entry → Application loop: starts
- Application loop → Config parser: parses settings
- Config parser → Matter settings: reads
- Config parser → Matter type mapping: maps type
- Config parser → Matter traits: produces
- Application loop → Cell grid: initializes and loads
- Cell grid → Cell defaults: builds defaults
- Cell grid → Matter traits: uses traits
- Material brush → Cell grid: creates cells
- Application loop → Material brush: handles input
- Application loop → Cell grid: steps simulation
- Cell grid → Update scheduler: queues updates
- Cell grid → Matter rules: dispatches steps
- Matter rules → Cell grid: checks and swaps
- Grid and HUD → Cell grid: reads cells
- Grid and HUD → Cell defaults: reads selected matter
- Application loop → Grid and HUD: draws frame
- Application loop → SFML window: polls and displays
- SFML window → Application loop: events and input
