# janecea/robotfight architecture

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

- Interactive diagram: https://gitdiagram.com/janecea/robotfight
- Repository: https://github.com/janecea/robotfight

## Overview

Robot Fight is a terminal programming game: users provide an arena and, on Linux, two C++ robot programs; the application loads configuration, validates the arena, runs a tick-based battle, and displays the result. The graph separates startup and robot integration, simulation, and terminal presentation, with a shared game model layer. Relationships are limited to calls or dependencies visible in the supplied excerpts and SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`source/main.cpp`](https://github.com/janecea/robotfight/blob/main/source/main.cpp) (Application Startup), [`source/models/game_logic/game_engine.cpp`](https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_engine.cpp) (Fight Engine), [`source/models/game_logic/game_state.hpp`](https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_state.hpp) (Match State), [`source/presenters/main_presenter.cpp`](https://github.com/janecea/robotfight/blob/main/source/presenters/main_presenter.cpp) (Game Presenter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and Inputs"]
  node_main["Application Startup<br/>[main.cpp]"]
  node_config["Configuration<br/>[game_config.cpp]"]
  node_arena_parser["Arena Parsing<br/>[arena_parser.cpp]"]
  node_robot_provider["Robot Tick Providers"]
  node_demo_provider["Demo Provider"]
end

subgraph group_simulation["Battle Simulation"]
  node_engine["Fight Engine<br/>[game_engine.cpp]"]
  node_robot_ai["Robot AI Adapter<br/>[robot_ai.cpp]"]
  node_state_view["AI State View"]
end

subgraph group_model["Game Model"]
  node_actions["Combat Actions<br/>[action.hpp]"]
  node_game_state["Match State<br/>[game_state.hpp]"]
  node_entities["Arena Entities<br/>[entities.hpp]"]
  node_arena_layout["Arena Layout<br/>[arena_layout.hpp]"]
  node_game_math["Game Mathematics<br/>[game_math.cpp]"]
  node_primitive_types["Shared Types"]
end

subgraph group_ui["Terminal Presentation"]
  node_presenter["Game Presenter<br/>[main_presenter.cpp]"]
  node_renderer["Arena Renderer<br/>[arena_renderer.cpp]"]
  node_frame["Terminal Frame<br/>[frame.cpp]"]
  node_view["Terminal View<br/>[main_view.cpp]"]
end

node_user(("Game User"))

node_user -->|"starts with inputs"| node_main
node_main -->|"loads configuration"| node_config
node_main -->|"parses arena"| node_arena_parser
node_main -->|"loads robot programs"| node_robot_provider
node_main -->|"selects demo robots"| node_demo_provider
node_main -->|"constructs match"| node_engine
node_main -->|"starts presentation"| node_presenter
node_arena_parser -->|"produces layout"| node_arena_layout
node_robot_provider -.->|"provides tick actions"| node_robot_ai
node_demo_provider -->|"provides tick actions"| node_robot_ai
node_engine -.->|"requests robot actions"| node_robot_ai
node_robot_ai -->|"queries match snapshot"| node_state_view
node_engine -->|"updates match state"| node_game_state
node_engine -->|"uses simulation helpers"| node_game_math
node_engine -->|"dispatches actions"| node_actions
node_game_state -->|"stores arena"| node_arena_layout
node_game_state -->|"stores entities"| node_entities
node_game_math -->|"checks walkability"| node_arena_layout
node_game_math -->|"updates robot damage"| node_entities
node_state_view -->|"reads snapshot"| node_game_state
node_presenter -->|"advances match"| node_engine
node_presenter -->|"renders snapshots"| node_renderer
node_presenter -->|"publishes UI data"| node_view
node_renderer -->|"reads match state"| node_game_state
node_renderer -->|"uses geometry helpers"| node_game_math
node_renderer -->|"composes frame"| node_frame
node_view -->|"displays frame"| node_frame
node_arena_layout -.-> node_primitive_types
node_entities -->|"uses shared types"| node_primitive_types
node_actions -->|"uses shared types"| node_primitive_types

click node_main "https://github.com/janecea/robotfight/blob/main/source/main.cpp"
click node_config "https://github.com/janecea/robotfight/blob/main/source/game_config.cpp"
click node_arena_parser "https://github.com/janecea/robotfight/blob/main/source/boot/arena_parser.cpp"
click node_robot_provider "https://github.com/janecea/robotfight/blob/main/source/boot/linux_on_tick_provider.cpp"
click node_demo_provider "https://github.com/janecea/robotfight/blob/main/source/boot/demo_on_tick_provider.cpp"
click node_engine "https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_engine.cpp"
click node_robot_ai "https://github.com/janecea/robotfight/blob/main/source/models/entities/robot_ai.cpp"
click node_state_view "https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_state_view.cpp"
click node_actions "https://github.com/janecea/robotfight/blob/main/source/models/actions/action.hpp"
click node_game_state "https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_state.hpp"
click node_entities "https://github.com/janecea/robotfight/blob/main/source/models/entities/entities.hpp"
click node_arena_layout "https://github.com/janecea/robotfight/blob/main/source/models/arena_layout.hpp"
click node_game_math "https://github.com/janecea/robotfight/blob/main/source/models/game_math.cpp"
click node_primitive_types "https://github.com/janecea/robotfight/blob/main/source/primitive_types.hpp"
click node_presenter "https://github.com/janecea/robotfight/blob/main/source/presenters/main_presenter.cpp"
click node_renderer "https://github.com/janecea/robotfight/blob/main/source/rendering/arena_renderer.cpp"
click node_frame "https://github.com/janecea/robotfight/blob/main/source/rendering/frame.cpp"
click node_view "https://github.com/janecea/robotfight/blob/main/source/views/main_view.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_config,node_arena_parser,node_robot_provider,node_demo_provider,node_user toneBlue
class node_engine,node_robot_ai,node_state_view toneAmber
class node_actions,node_game_state,node_entities,node_arena_layout,node_game_math,node_primitive_types toneMint
class node_presenter,node_renderer,node_frame,node_view toneRose
```

## Components

### Startup and Inputs

- [Application Startup](https://github.com/janecea/robotfight/blob/main/source/main.cpp): `source/main.cpp`
- [Configuration](https://github.com/janecea/robotfight/blob/main/source/game_config.cpp): `source/game_config.cpp`
- [Arena Parsing](https://github.com/janecea/robotfight/blob/main/source/boot/arena_parser.cpp): `source/boot/arena_parser.cpp`
- [Robot Tick Providers](https://github.com/janecea/robotfight/blob/main/source/boot/linux_on_tick_provider.cpp): `source/boot/linux_on_tick_provider.cpp`
- [Demo Provider](https://github.com/janecea/robotfight/blob/main/source/boot/demo_on_tick_provider.cpp): `source/boot/demo_on_tick_provider.cpp`

### Battle Simulation

- [Fight Engine](https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_engine.cpp): `source/models/game_logic/game_engine.cpp`
- [Robot AI Adapter](https://github.com/janecea/robotfight/blob/main/source/models/entities/robot_ai.cpp): `source/models/entities/robot_ai.cpp`
- [AI State View](https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_state_view.cpp): `source/models/game_logic/game_state_view.cpp`

### Game Model

- [Combat Actions](https://github.com/janecea/robotfight/blob/main/source/models/actions/action.hpp): `source/models/actions/action.hpp`
- [Match State](https://github.com/janecea/robotfight/blob/main/source/models/game_logic/game_state.hpp): `source/models/game_logic/game_state.hpp`
- [Arena Entities](https://github.com/janecea/robotfight/blob/main/source/models/entities/entities.hpp): `source/models/entities/entities.hpp`
- [Arena Layout](https://github.com/janecea/robotfight/blob/main/source/models/arena_layout.hpp): `source/models/arena_layout.hpp`
- [Game Mathematics](https://github.com/janecea/robotfight/blob/main/source/models/game_math.cpp): `source/models/game_math.cpp`
- [Shared Types](https://github.com/janecea/robotfight/blob/main/source/primitive_types.hpp): `source/primitive_types.hpp`

### Terminal Presentation

- [Game Presenter](https://github.com/janecea/robotfight/blob/main/source/presenters/main_presenter.cpp): `source/presenters/main_presenter.cpp`
- [Arena Renderer](https://github.com/janecea/robotfight/blob/main/source/rendering/arena_renderer.cpp): `source/rendering/arena_renderer.cpp`
- [Terminal Frame](https://github.com/janecea/robotfight/blob/main/source/rendering/frame.cpp): `source/rendering/frame.cpp`
- [Terminal View](https://github.com/janecea/robotfight/blob/main/source/views/main_view.cpp): `source/views/main_view.cpp`

### Other components

- **Game User**

## Connections

- Game User → Application Startup: starts with inputs (evidence: `README.md`)
- Application Startup → Configuration: loads configuration (evidence: `source/main.cpp`)
- Application Startup → Arena Parsing: parses arena (evidence: `source/main.cpp`)
- Application Startup → Robot Tick Providers: loads robot programs (evidence: `source/main.cpp`)
- Application Startup → Demo Provider: selects demo robots (evidence: `source/main.cpp`)
- Application Startup → Fight Engine: constructs match (evidence: `source/main.cpp`)
- Application Startup → Game Presenter: starts presentation (evidence: `source/main.cpp`)
- Arena Parsing → Arena Layout: produces layout
- Robot Tick Providers → Robot AI Adapter: provides tick actions
- Demo Provider → Robot AI Adapter: provides tick actions
- Fight Engine → Robot AI Adapter: requests robot actions
- Robot AI Adapter → AI State View: queries match snapshot (evidence: `source/models/entities/robot_ai.cpp`)
- Fight Engine → Match State: updates match state
- Fight Engine → Game Mathematics: uses simulation helpers (evidence: `source/models/game_logic/game_engine.cpp`)
- Fight Engine → Combat Actions: dispatches actions
- Match State → Arena Layout: stores arena (evidence: `source/models/game_logic/game_state.hpp`)
- Match State → Arena Entities: stores entities (evidence: `source/models/game_logic/game_state.hpp`)
- Game Mathematics → Arena Layout: checks walkability
- Game Mathematics → Arena Entities: updates robot damage
- AI State View → Match State: reads snapshot
- Game Presenter → Fight Engine: advances match
- Game Presenter → Arena Renderer: renders snapshots
- Game Presenter → Terminal View: publishes UI data
- Arena Renderer → Match State: reads match state
- Arena Renderer → Game Mathematics: uses geometry helpers
- Arena Renderer → Terminal Frame: composes frame
- Terminal View → Terminal Frame: displays frame
- Arena Layout → Shared Types
- Arena Entities → Shared Types: uses shared types (evidence: `source/models/entities/entities.hpp`)
- Combat Actions → Shared Types: uses shared types (evidence: `source/models/actions/action.hpp`)
