# tyreece614/simulation architecture

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

- Interactive diagram: https://gitdiagram.com/tyreece614/simulation
- Repository: https://github.com/tyreece614/simulation

## Overview

This is a small SFML predator–prey simulation. The main workflow creates populations, renders them in a window, moves prey away from nearby predators and predators toward nearby prey, then removes caught prey. Core animal state and distance calculation support that loop. The README also describes a developing menu and future user controls, but the tree and excerpts do not identify an implementing module. The `dev/` tree duplicates the main source; its runtime role is unclear, so it is shown separately without inferred connections.

Main entry points: [`Simulation.cpp`](https://github.com/tyreece614/simulation/blob/main/Simulation.cpp) (Simulation and rendering), [`Prey.cpp`](https://github.com/tyreece614/simulation/blob/main/Prey.cpp) (Prey behavior), [`dev/Simulation.cpp`](https://github.com/tyreece614/simulation/blob/main/dev/Simulation.cpp) (Development simulation copy), [`dev/Prey.cpp`](https://github.com/tyreece614/simulation/blob/main/dev/Prey.cpp) (Development prey)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_loop["Simulation loop"]
  node_sim["Simulation and rendering<br/>[Simulation.cpp]"]
  node_population["Population and targeting<br/>[Simulation.cpp]"]
  node_collision["Overlap and catch removal<br/>[Simulation.cpp]"]
end

subgraph group_species["Animal model"]
  node_animal["Animal state<br/>[Animal.cpp]"]
  node_predator["Predator behavior<br/>[Predator.cpp]"]
  node_prey["Prey behavior<br/>[Prey.cpp]"]
end

subgraph group_support["Shared support"]
  node_distance["Distance utility<br/>[Utilities.cpp]"]
end

subgraph group_devcopy["Development copy"]
  node_devsim["Development simulation copy<br/>[Simulation.cpp]"]
  node_devanimal["Development animal state<br/>[Animal.cpp]"]
  node_devpredator["Development predator<br/>[Predator.cpp]"]
  node_devprey["Development prey<br/>[Prey.cpp]"]
  node_devdistance["Development distance utility<br/>[Utilities.cpp]"]
end

node_user(("User"))

node_user -->|"opens window"| node_sim
node_sim -->|"creates populations"| node_population
node_sim -->|"renders and moves"| node_predator
node_sim -->|"renders and moves"| node_prey
node_sim -->|"checks catches"| node_collision
node_population -->|"creates and targets"| node_predator
node_population -->|"creates and targets"| node_prey
node_predator -->|"inherits state"| node_animal
node_prey -->|"inherits state"| node_animal
node_prey -->|"measures distance"| node_distance
node_devsim -.->|"uses state"| node_devanimal
node_devsim -.->|"uses predator"| node_devpredator
node_devsim -.->|"uses prey"| node_devprey
node_devpredator -->|"inherits state"| node_devanimal
node_devprey -->|"inherits state"| node_devanimal
node_devprey -.->|"measures distance"| node_devdistance

click node_sim "https://github.com/tyreece614/simulation/blob/main/Simulation.cpp"
click node_population "https://github.com/tyreece614/simulation/blob/main/Simulation.cpp"
click node_collision "https://github.com/tyreece614/simulation/blob/main/Simulation.cpp"
click node_animal "https://github.com/tyreece614/simulation/blob/main/Animal.cpp"
click node_predator "https://github.com/tyreece614/simulation/blob/main/Predator.cpp"
click node_prey "https://github.com/tyreece614/simulation/blob/main/Prey.cpp"
click node_distance "https://github.com/tyreece614/simulation/blob/main/Utilities.cpp"
click node_devsim "https://github.com/tyreece614/simulation/blob/main/dev/Simulation.cpp"
click node_devanimal "https://github.com/tyreece614/simulation/blob/main/dev/Animal.cpp"
click node_devpredator "https://github.com/tyreece614/simulation/blob/main/dev/Predator.cpp"
click node_devprey "https://github.com/tyreece614/simulation/blob/main/dev/Prey.cpp"
click node_devdistance "https://github.com/tyreece614/simulation/blob/main/dev/Utilities.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_sim,node_population,node_collision,node_user toneBlue
class node_animal,node_predator,node_prey toneAmber
class node_distance toneMint
class node_devsim,node_devanimal,node_devpredator,node_devprey,node_devdistance toneRose
```

## Components

### Simulation loop

- [Simulation and rendering](https://github.com/tyreece614/simulation/blob/main/Simulation.cpp): `Simulation.cpp`
- [Population and targeting](https://github.com/tyreece614/simulation/blob/main/Simulation.cpp): `Simulation.cpp`
- [Overlap and catch removal](https://github.com/tyreece614/simulation/blob/main/Simulation.cpp): `Simulation.cpp`

### Animal model

- [Animal state](https://github.com/tyreece614/simulation/blob/main/Animal.cpp): `Animal.cpp`
- [Predator behavior](https://github.com/tyreece614/simulation/blob/main/Predator.cpp): `Predator.cpp`
- [Prey behavior](https://github.com/tyreece614/simulation/blob/main/Prey.cpp): `Prey.cpp`

### Shared support

- [Distance utility](https://github.com/tyreece614/simulation/blob/main/Utilities.cpp): `Utilities.cpp`

### Development copy

- [Development simulation copy](https://github.com/tyreece614/simulation/blob/main/dev/Simulation.cpp): `dev/Simulation.cpp`
- [Development animal state](https://github.com/tyreece614/simulation/blob/main/dev/Animal.cpp): `dev/Animal.cpp`
- [Development predator](https://github.com/tyreece614/simulation/blob/main/dev/Predator.cpp): `dev/Predator.cpp`
- [Development prey](https://github.com/tyreece614/simulation/blob/main/dev/Prey.cpp): `dev/Prey.cpp`
- [Development distance utility](https://github.com/tyreece614/simulation/blob/main/dev/Utilities.cpp): `dev/Utilities.cpp`

### Other components

- **User**

## Connections

- User → Simulation and rendering: opens window (evidence: `README.md`)
- Simulation and rendering → Population and targeting: creates populations (evidence: `Simulation.cpp`)
- Simulation and rendering → Predator behavior: renders and moves (evidence: `Simulation.cpp`)
- Simulation and rendering → Prey behavior: renders and moves (evidence: `Simulation.cpp`)
- Simulation and rendering → Overlap and catch removal: checks catches (evidence: `Simulation.cpp`)
- Population and targeting → Predator behavior: creates and targets (evidence: `Simulation.cpp`)
- Population and targeting → Prey behavior: creates and targets (evidence: `Simulation.cpp`)
- Predator behavior → Animal state: inherits state
- Prey behavior → Animal state: inherits state
- Prey behavior → Distance utility: measures distance (evidence: `Prey.cpp`)
- Development simulation copy → Development animal state: uses state
- Development simulation copy → Development predator: uses predator
- Development simulation copy → Development prey: uses prey
- Development predator → Development animal state: inherits state
- Development prey → Development animal state: inherits state
- Development prey → Development distance utility: measures distance
