# ltom19/formaitions architecture

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

- Interactive diagram: https://gitdiagram.com/ltom19/formaitions
- Repository: https://github.com/ltom19/formaitions

## Overview

FormAItions is a Python battle-simulation skeleton for the Carrhae scenario, not yet a functioning simulator: the README says function bodies still raise NotImplementedError. Its intended workflow is for two generals to read battle observations and return orders, which Carrhae passes through simulation steps to produce a BattleResult. The tree also preserves map/placement, combat, formations, campaign/save/victory, and battle-view capabilities. Several source modules were not excerpted, so unsampled subsystem links are omitted rather than inferred.

Main entry points: [`src/formaitions/scenario/carrhae.py`](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/carrhae.py) (Carrhae runner), [`src/formaitions/ia/crassus.py`](https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/crassus.py) (Crassus AI), [`src/formaitions/formations/commands.py`](https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/commands.py) (Formation commands), [`src/formaitions/simulation/carte.py`](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/carte.py) (Map and terrain)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_domain["Shared domain"]
  node_contracts["Battle contracts<br/>[contracts.py]"]
  node_stats["Rule constants<br/>[stats.py]"]
end

subgraph group_scenario["Scenario flow"]
  node_carrhae["Carrhae runner<br/>[carrhae.py]"]
  node_placement["Army placement<br/>[placement.py]"]
  node_campaign["Campaign<br/>[campagne.py]"]
  node_saving["Battle save<br/>[save.py]"]
  node_victory["Victory outcome<br/>[victoire.py]"]
end

subgraph group_simulation["Battle simulation"]
  node_map["Map and terrain<br/>[carte.py]"]
  node_world["World state<br/>[monde.py]"]
  node_step["Simulation step<br/>[step.py]"]
  node_movement["Unit movement<br/>[mouvement.py]"]
  node_collision["Collision rules<br/>[collision.py]"]
  node_combat["Combat resolution<br/>[combat.py]"]
end

subgraph group_strategy["Generals and formations"]
  node_crassus["Crassus AI<br/>[crassus.py]"]
  node_surena["Surena AI<br/>[surena.py]"]
  node_braindead["Braindead AI<br/>[braindead.py]"]
  node_bedlam["Bedlam AI<br/>[bedlam.py]"]
  node_shapes["Formation shapes<br/>[shapes.py]"]
  node_formation["Formation state<br/>[model.py]"]
  node_commands["Formation commands<br/>[commands.py]"]
end

subgraph group_presentation["Battle view"]
  node_battle_view["Battle display<br/>[bataille.py]"]
  node_playback["Playback controls<br/>[playback.py]"]
  node_spike["Isometric display spike<br/>[spike.py]"]
end

node_user(("Battle operator"))

node_user -.->|"starts battle"| node_carrhae
node_carrhae -->|"requests decisions"| node_crassus
node_carrhae -->|"requests decisions"| node_surena
node_carrhae -->|"advances simulation"| node_step
node_carrhae -->|"reads speed"| node_playback
node_placement -->|"reads terrain"| node_map
node_step -->|"uses world state"| node_world
node_collision -->|"checks terrain"| node_map
node_combat -->|"checks map"| node_map
node_crassus -->|"gets slots"| node_shapes
node_crassus -->|"translates commands"| node_commands
node_commands -->|"uses formation"| node_formation
node_commands -->|"uses shape"| node_shapes
node_battle_view -->|"uses controls"| node_playback

click node_contracts "https://github.com/ltom19/formaitions/blob/main/src/formaitions/domaine/contracts.py"
click node_stats "https://github.com/ltom19/formaitions/blob/main/src/formaitions/domaine/stats.py"
click node_carrhae "https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/carrhae.py"
click node_placement "https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/placement.py"
click node_campaign "https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/campagne.py"
click node_saving "https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/save.py"
click node_victory "https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/victoire.py"
click node_map "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/carte.py"
click node_world "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/monde.py"
click node_step "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/step.py"
click node_movement "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/mouvement.py"
click node_collision "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/collision.py"
click node_combat "https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/combat.py"
click node_crassus "https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/crassus.py"
click node_surena "https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/surena.py"
click node_braindead "https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/braindead.py"
click node_bedlam "https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/bedlam.py"
click node_shapes "https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/shapes.py"
click node_formation "https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/model.py"
click node_commands "https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/commands.py"
click node_battle_view "https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/bataille.py"
click node_playback "https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/playback.py"
click node_spike "https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/spike.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_contracts,node_stats toneBlue
class node_carrhae,node_placement,node_campaign,node_saving,node_victory toneAmber
class node_map,node_world,node_step,node_movement,node_collision,node_combat toneMint
class node_crassus,node_surena,node_braindead,node_bedlam,node_shapes,node_formation,node_commands toneRose
class node_battle_view,node_playback,node_spike,node_user toneIndigo
```

## Components

### Shared domain

- [Battle contracts](https://github.com/ltom19/formaitions/blob/main/src/formaitions/domaine/contracts.py): `src/formaitions/domaine/contracts.py`
- [Rule constants](https://github.com/ltom19/formaitions/blob/main/src/formaitions/domaine/stats.py): `src/formaitions/domaine/stats.py`

### Scenario flow

- [Carrhae runner](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/carrhae.py): `src/formaitions/scenario/carrhae.py`
- [Army placement](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/placement.py): `src/formaitions/scenario/placement.py`
- [Campaign](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/campagne.py): `src/formaitions/scenario/campagne.py`
- [Battle save](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/save.py): `src/formaitions/scenario/save.py`
- [Victory outcome](https://github.com/ltom19/formaitions/blob/main/src/formaitions/scenario/victoire.py): `src/formaitions/scenario/victoire.py`

### Battle simulation

- [Map and terrain](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/carte.py): `src/formaitions/simulation/carte.py`
- [World state](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/monde.py): `src/formaitions/simulation/monde.py`
- [Simulation step](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/step.py): `src/formaitions/simulation/step.py`
- [Unit movement](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/mouvement.py): `src/formaitions/simulation/mouvement.py`
- [Collision rules](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/collision.py): `src/formaitions/simulation/collision.py`
- [Combat resolution](https://github.com/ltom19/formaitions/blob/main/src/formaitions/simulation/combat.py): `src/formaitions/simulation/combat.py`

### Generals and formations

- [Crassus AI](https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/crassus.py): `src/formaitions/ia/crassus.py`
- [Surena AI](https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/surena.py): `src/formaitions/ia/surena.py`
- [Braindead AI](https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/braindead.py): `src/formaitions/ia/braindead.py`
- [Bedlam AI](https://github.com/ltom19/formaitions/blob/main/src/formaitions/ia/bedlam.py): `src/formaitions/ia/bedlam.py`
- [Formation shapes](https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/shapes.py): `src/formaitions/formations/shapes.py`
- [Formation state](https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/model.py): `src/formaitions/formations/model.py`
- [Formation commands](https://github.com/ltom19/formaitions/blob/main/src/formaitions/formations/commands.py): `src/formaitions/formations/commands.py`

### Battle view

- [Battle display](https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/bataille.py): `src/formaitions/vue/bataille.py`
- [Playback controls](https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/playback.py): `src/formaitions/vue/playback.py`
- [Isometric display spike](https://github.com/ltom19/formaitions/blob/main/src/formaitions/vue/spike.py): `src/formaitions/vue/spike.py`

### Other components

- **Battle operator**

## Connections

- Battle operator → Carrhae runner: starts battle
- Carrhae runner → Crassus AI: requests decisions (evidence: `src/formaitions/scenario/carrhae.py`)
- Carrhae runner → Surena AI: requests decisions (evidence: `src/formaitions/scenario/carrhae.py`)
- Carrhae runner → Simulation step: advances simulation (evidence: `src/formaitions/scenario/carrhae.py`)
- Carrhae runner → Playback controls: reads speed (evidence: `src/formaitions/vue/playback.py`)
- Army placement → Map and terrain: reads terrain (evidence: `src/formaitions/scenario/placement.py`)
- Simulation step → World state: uses world state (evidence: `src/formaitions/simulation/step.py`)
- Collision rules → Map and terrain: checks terrain (evidence: `src/formaitions/simulation/collision.py`)
- Combat resolution → Map and terrain: checks map (evidence: `src/formaitions/simulation/combat.py`)
- Crassus AI → Formation shapes: gets slots (evidence: `src/formaitions/ia/crassus.py`)
- Crassus AI → Formation commands: translates commands (evidence: `src/formaitions/ia/crassus.py`)
- Formation commands → Formation state: uses formation (evidence: `src/formaitions/formations/commands.py`)
- Formation commands → Formation shapes: uses shape (evidence: `src/formaitions/formations/commands.py`)
- Battle display → Playback controls: uses controls (evidence: `src/formaitions/vue/bataille.py`)
