# ciubotaru/feud architecture

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

- Interactive diagram: https://gitdiagram.com/ciubotaru/feud
- Repository: https://github.com/ciubotaru/feud

## Overview

Feud is a local turn-based medieval strategy game with an editor, hot-seat play, and a weak computer opponent. Players build or load a world, then manage its map, characters, pieces, regions, and diplomacy while playing. The graph separates the documented entry modes and editor/game interaction from the shared game rules and state, plus persistence and world-generation capabilities. Some subsystem links rely on README descriptions or source-index references; unsampled implementation details are not inferred.

Main entry points: [`world.c`](https://github.com/ciubotaru/feud/blob/stable/world.c) (Shared world state), [`editor.c`](https://github.com/ciubotaru/feud/blob/stable/editor.c) (World editor), [`ai.c`](https://github.com/ciubotaru/feud/blob/stable/ai.c) (AI game), [`window.c`](https://github.com/ciubotaru/feud/blob/stable/window.c) (Game interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Game entry modes"]
  node_editor["World editor<br/>[editor.c]"]
  node_hotseat["Hot-seat game<br/>[single.c]"]
  node_ai["AI game<br/>[ai.c]"]
  node_command["Setup commands<br/>[server.c]"]
  node_terminal["Game interface<br/>[window.c]"]
end

subgraph group_world["World creation and editing"]
  node_map["Grid and regions<br/>[map.c]"]
  node_mapgen["Map generation<br/>[mapgen.c]"]
  node_newworld["World wizard<br/>[new.c]"]
end

subgraph group_rules["Game state and rules"]
  node_worldstate["Shared world state<br/>[world.c]"]
  node_characters["Characters and succession<br/>[character.c]"]
  node_pieces["Military pieces<br/>[piece.c]"]
  node_diplomacy["Diplomacy and vassals<br/>[diplomacy.c]"]
  node_logic["Game rules<br/>[logic.c]"]
  node_dice["Dice mechanics<br/>[dice.c]"]
  node_time["Game time<br/>[time.c]"]
end

subgraph group_support["Persistence and presentation"]
  node_save[("Save and load<br/>[file.c]")]
  node_pipe["Input handling<br/>[pipe.c]"]
  node_chronicle["Game history<br/>[feud.c]"]
end

node_players(("Local players"))
node_computer(("Computer opponent"))

node_players -->|"edit world"| node_editor
node_players -->|"play locally"| node_hotseat
node_computer -->|"play against"| node_ai
node_players -->|"choose character"| node_ai
node_editor -->|"use editor screens"| node_terminal
node_hotseat -.->|"play through"| node_terminal
node_ai -->|"create grid"| node_map
node_ai -->|"validate setup"| node_worldstate
node_editor -.->|"edit shared state"| node_worldstate
node_command -.->|"manage game setup"| node_worldstate
node_worldstate -->|"holds grid and regions"| node_map
node_worldstate -->|"holds character list"| node_characters
node_worldstate -->|"holds piece list"| node_pieces
node_worldstate -->|"holds diplomacy list"| node_diplomacy
node_map -->|"check relations"| node_diplomacy
node_characters -->|"remove relations"| node_diplomacy
node_editor -.->|"generate maps"| node_mapgen
node_editor -->|"create simple world"| node_newworld
node_worldstate -->|"serialize world"| node_save
node_save -->|"restore world"| node_worldstate
node_terminal -->|"manage characters"| node_characters
node_terminal -->|"manage diplomacy"| node_diplomacy
node_logic -.->|"use dice mechanics"| node_dice
node_worldstate -->|"stores current time"| node_time
node_pipe -.->|"feed commands"| node_command
node_worldstate -.->|"record events"| node_chronicle

click node_editor "https://github.com/ciubotaru/feud/blob/stable/editor.c"
click node_hotseat "https://github.com/ciubotaru/feud/blob/stable/single.c"
click node_ai "https://github.com/ciubotaru/feud/blob/stable/ai.c"
click node_command "https://github.com/ciubotaru/feud/blob/stable/server.c"
click node_terminal "https://github.com/ciubotaru/feud/blob/stable/window.c"
click node_worldstate "https://github.com/ciubotaru/feud/blob/stable/world.c"
click node_map "https://github.com/ciubotaru/feud/blob/stable/map.c"
click node_mapgen "https://github.com/ciubotaru/feud/blob/stable/mapgen.c"
click node_newworld "https://github.com/ciubotaru/feud/blob/stable/new.c"
click node_characters "https://github.com/ciubotaru/feud/blob/stable/character.c"
click node_pieces "https://github.com/ciubotaru/feud/blob/stable/piece.c"
click node_diplomacy "https://github.com/ciubotaru/feud/blob/stable/diplomacy.c"
click node_logic "https://github.com/ciubotaru/feud/blob/stable/logic.c"
click node_dice "https://github.com/ciubotaru/feud/blob/stable/dice.c"
click node_time "https://github.com/ciubotaru/feud/blob/stable/time.c"
click node_save "https://github.com/ciubotaru/feud/blob/stable/file.c"
click node_pipe "https://github.com/ciubotaru/feud/blob/stable/pipe.c"
click node_chronicle "https://github.com/ciubotaru/feud/blob/stable/feud.c"

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_editor,node_hotseat,node_ai,node_command,node_terminal toneBlue
class node_map,node_mapgen,node_newworld toneAmber
class node_worldstate,node_characters,node_pieces,node_diplomacy,node_logic,node_dice,node_time toneMint
class node_save,node_pipe,node_chronicle toneRose
class node_players,node_computer toneIndigo
```

## Components

### Game entry modes

- [World editor](https://github.com/ciubotaru/feud/blob/stable/editor.c): `editor.c`
- [Hot-seat game](https://github.com/ciubotaru/feud/blob/stable/single.c): `single.c`
- [AI game](https://github.com/ciubotaru/feud/blob/stable/ai.c): `ai.c`
- [Setup commands](https://github.com/ciubotaru/feud/blob/stable/server.c): `server.c`
- [Game interface](https://github.com/ciubotaru/feud/blob/stable/window.c): `window.c`

### World creation and editing

- [Grid and regions](https://github.com/ciubotaru/feud/blob/stable/map.c): `map.c`
- [Map generation](https://github.com/ciubotaru/feud/blob/stable/mapgen.c): `mapgen.c`
- [World wizard](https://github.com/ciubotaru/feud/blob/stable/new.c): `new.c`

### Game state and rules

- [Shared world state](https://github.com/ciubotaru/feud/blob/stable/world.c): `world.c`
- [Characters and succession](https://github.com/ciubotaru/feud/blob/stable/character.c): `character.c`
- [Military pieces](https://github.com/ciubotaru/feud/blob/stable/piece.c): `piece.c`
- [Diplomacy and vassals](https://github.com/ciubotaru/feud/blob/stable/diplomacy.c): `diplomacy.c`
- [Game rules](https://github.com/ciubotaru/feud/blob/stable/logic.c): `logic.c`
- [Dice mechanics](https://github.com/ciubotaru/feud/blob/stable/dice.c): `dice.c`
- [Game time](https://github.com/ciubotaru/feud/blob/stable/time.c): `time.c`

### Persistence and presentation

- [Save and load](https://github.com/ciubotaru/feud/blob/stable/file.c): `file.c`
- [Input handling](https://github.com/ciubotaru/feud/blob/stable/pipe.c): `pipe.c`
- [Game history](https://github.com/ciubotaru/feud/blob/stable/feud.c): `feud.c`

### Other components

- **Local players**
- **Computer opponent**

## Connections

- Local players → World editor: edit world (evidence: `README`)
- Local players → Hot-seat game: play locally (evidence: `README`)
- Computer opponent → AI game: play against (evidence: `README`)
- Local players → AI game: choose character (evidence: `README`)
- World editor → Game interface: use editor screens (evidence: `README`)
- Hot-seat game → Game interface: play through
- AI game → Grid and regions: create grid (evidence: `ai.c`)
- AI game → Shared world state: validate setup (evidence: `ai.c`)
- World editor → Shared world state: edit shared state
- Setup commands → Shared world state: manage game setup
- Shared world state → Grid and regions: holds grid and regions
- Shared world state → Characters and succession: holds character list
- Shared world state → Military pieces: holds piece list
- Shared world state → Diplomacy and vassals: holds diplomacy list
- Grid and regions → Diplomacy and vassals: check relations (evidence: `map.c`)
- Characters and succession → Diplomacy and vassals: remove relations (evidence: `character.c`)
- World editor → Map generation: generate maps
- World editor → World wizard: create simple world (evidence: `README`)
- Shared world state → Save and load: serialize world (evidence: `file.c`)
- Save and load → Shared world state: restore world (evidence: `file.c`)
- Game interface → Characters and succession: manage characters (evidence: `window.c`)
- Game interface → Diplomacy and vassals: manage diplomacy (evidence: `window.c`)
- Game rules → Dice mechanics: use dice mechanics
- Shared world state → Game time: stores current time
- Input handling → Setup commands: feed commands
- Shared world state → Game history: record events
