# showerss/gametrainersharp architecture

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

- Interactive diagram: https://gitdiagram.com/showerss/gametrainersharp
- Repository: https://github.com/showerss/gametrainersharp

## Overview

GameTrainerSharp trains generational reinforcement-learning agents on GridWorld tasks, then presents run history and metrics in an Avalonia observatory. The main workflow configures a game and training run, steps a dual-modal environment, trains or coaches a policy, and records models and metrics for dashboard review. The graph preserves the vector/visual policy stages, GridWorld variants, local catalog, and dashboard. Relationships are cited from excerpts, the source index, or README; unsampled modules are represented only where documented or listed in the index.

Main entry points: [`src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs`](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs) (GridWorld environment), [`src/GameTrainer.Runner/Program.cs`](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Runner/Program.cs) (CLI runner), [`src/GameTrainer.Gui/MainWindow.cs`](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/MainWindow.cs) (Observatory window), [`src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs`](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs) (Game descriptors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Training workflow"]
  node_runner["CLI runner<br/>[Program.cs]"]
  node_contracts["Environment contracts<br/>[GameTrainer.Core]"]
end

subgraph group_game["GridWorld domain"]
  node_descriptor["Game descriptors"]
  node_grid_env["GridWorld environment"]
  node_random_env["Random-start task"]
  node_state["Grid state projections<br/>[GridState.cs]"]
  node_spawners["Start strategies"]
  node_rules["Movement rules<br/>[GridWorldRules.cs]"]
  node_rewards["Reward calculation"]
end

subgraph group_brain["Learning system"]
  node_trainer["Generational PPO"]
  node_policy["Modular policy<br/>[ModularPolicy.cs]"]
end

subgraph group_observatory["Catalog observatory"]
  node_catalog[("Catalog and run store<br/>[CatalogStore.cs]")]
  node_catalog_models["Catalog records<br/>[CatalogModels.cs]"]
  node_dashboard_vm["Dashboard view model"]
  node_dashboard["Observatory window<br/>[MainWindow.cs]"]
  node_chart["Improvement chart"]
  node_theme["Classic theme<br/>[Win2000Theme.cs]"]
  node_gui_app["GUI application<br/>[App.cs]"]
end

node_user(("Trainer user"))

node_user -->|"configures run"| node_runner
node_runner -->|"selects game"| node_descriptor
node_descriptor -->|"creates task"| node_grid_env
node_descriptor -->|"creates variant"| node_random_env
node_runner -->|"starts training"| node_trainer
node_trainer -->|"trains policy"| node_policy
node_trainer -->|"uses environment"| node_contracts
node_policy -->|"reads observations"| node_contracts
node_grid_env -->|"steps state"| node_rules
node_grid_env -->|"initializes state"| node_spawners
node_grid_env -->|"uses rewards"| node_rewards
node_rules -->|"updates state"| node_state
node_state -->|"renders frame"| node_contracts
node_random_env -->|"delegates steps"| node_grid_env
node_random_env -->|"configures start"| node_spawners
node_runner -->|"records runs"| node_catalog
node_catalog -->|"serializes records"| node_catalog_models
node_dashboard_vm -->|"reads run data"| node_catalog
node_dashboard_vm -->|"uses game metadata"| node_descriptor
node_gui_app -->|"opens window"| node_dashboard
node_dashboard -->|"presents data"| node_dashboard_vm
node_dashboard -->|"renders metrics"| node_chart
node_dashboard -->|"applies styling"| node_theme
node_chart -->|"uses styling"| node_theme

click node_runner "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Runner/Program.cs"
click node_contracts "https://github.com/showerss/gametrainersharp/tree/main/src/GameTrainer.Core"
click node_descriptor "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs"
click node_grid_env "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs"
click node_random_env "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/RandomStartEnvironment.cs"
click node_state "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridState.cs"
click node_spawners "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldSpawners.cs"
click node_rules "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldRules.cs"
click node_rewards "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/RewardCalculator.cs"
click node_trainer "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Brain/GenerationalPpoTrainer.cs"
click node_policy "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Brain/ModularPolicy.cs"
click node_catalog "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Core/Catalog/CatalogStore.cs"
click node_catalog_models "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Core/Catalog/CatalogModels.cs"
click node_dashboard_vm "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/DashboardViewModel.cs"
click node_dashboard "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/MainWindow.cs"
click node_chart "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/ImprovementChartControl.cs"
click node_theme "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/Win2000Theme.cs"
click node_gui_app "https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/App.cs"

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_runner,node_contracts,node_user toneBlue
class node_descriptor,node_grid_env,node_random_env,node_state,node_spawners,node_rules,node_rewards toneAmber
class node_trainer,node_policy toneMint
class node_catalog,node_catalog_models,node_dashboard_vm,node_dashboard,node_chart,node_theme,node_gui_app toneRose
```

## Components

### Training workflow

- [CLI runner](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Runner/Program.cs): `src/GameTrainer.Runner/Program.cs`
- [Environment contracts](https://github.com/showerss/gametrainersharp/tree/main/src/GameTrainer.Core): `src/GameTrainer.Core`

### GridWorld domain

- [Game descriptors](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs): `src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs`
- [GridWorld environment](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs): `src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs`
- [Random-start task](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/RandomStartEnvironment.cs): `src/GameTrainer.Games/GridWorld/RandomStartEnvironment.cs`
- [Grid state projections](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridState.cs): `src/GameTrainer.Games/GridWorld/GridState.cs`
- [Start strategies](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldSpawners.cs): `src/GameTrainer.Games/GridWorld/GridWorldSpawners.cs`
- [Movement rules](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/GridWorldRules.cs): `src/GameTrainer.Games/GridWorld/GridWorldRules.cs`
- [Reward calculation](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Games/GridWorld/RewardCalculator.cs): `src/GameTrainer.Games/GridWorld/RewardCalculator.cs`

### Learning system

- [Generational PPO](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Brain/GenerationalPpoTrainer.cs): `src/GameTrainer.Brain/GenerationalPpoTrainer.cs`
- [Modular policy](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Brain/ModularPolicy.cs): `src/GameTrainer.Brain/ModularPolicy.cs`

### Catalog observatory

- [Catalog and run store](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Core/Catalog/CatalogStore.cs): `src/GameTrainer.Core/Catalog/CatalogStore.cs`
- [Catalog records](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Core/Catalog/CatalogModels.cs): `src/GameTrainer.Core/Catalog/CatalogModels.cs`
- [Dashboard view model](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/DashboardViewModel.cs): `src/GameTrainer.Gui/DashboardViewModel.cs`
- [Observatory window](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/MainWindow.cs): `src/GameTrainer.Gui/MainWindow.cs`
- [Improvement chart](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/ImprovementChartControl.cs): `src/GameTrainer.Gui/ImprovementChartControl.cs`
- [Classic theme](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/Win2000Theme.cs): `src/GameTrainer.Gui/Win2000Theme.cs`
- [GUI application](https://github.com/showerss/gametrainersharp/blob/main/src/GameTrainer.Gui/App.cs): `src/GameTrainer.Gui/App.cs`

### Other components

- **Trainer user**

## Connections

- Trainer user → CLI runner: configures run (evidence: `README.md`)
- CLI runner → Game descriptors: selects game (evidence: `src/GameTrainer.Runner/Program.cs`)
- Game descriptors → GridWorld environment: creates task (evidence: `src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs`)
- Game descriptors → Random-start task: creates variant (evidence: `src/GameTrainer.Games/GridWorld/GridWorldDescriptors.cs`)
- CLI runner → Generational PPO: starts training (evidence: `src/GameTrainer.Runner/Program.cs`)
- Generational PPO → Modular policy: trains policy (evidence: `src/GameTrainer.Brain/GenerationalPpoTrainer.cs`)
- Generational PPO → Environment contracts: uses environment (evidence: `src/GameTrainer.Brain/GenerationalPpoTrainer.cs`)
- Modular policy → Environment contracts: reads observations (evidence: `src/GameTrainer.Brain/ModularPolicy.cs`)
- GridWorld environment → Movement rules: steps state (evidence: `src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs`)
- GridWorld environment → Start strategies: initializes state (evidence: `src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs`)
- GridWorld environment → Reward calculation: uses rewards (evidence: `src/GameTrainer.Games/GridWorld/GridWorldEnvironment.cs`)
- Movement rules → Grid state projections: updates state (evidence: `src/GameTrainer.Games/GridWorld/GridWorldRules.cs`)
- Grid state projections → Environment contracts: renders frame (evidence: `src/GameTrainer.Games/GridWorld/GridState.cs`)
- Random-start task → GridWorld environment: delegates steps (evidence: `src/GameTrainer.Games/GridWorld/RandomStartEnvironment.cs`)
- Random-start task → Start strategies: configures start (evidence: `src/GameTrainer.Games/GridWorld/RandomStartEnvironment.cs`)
- CLI runner → Catalog and run store: records runs (evidence: `src/GameTrainer.Runner/Program.cs`)
- Catalog and run store → Catalog records: serializes records (evidence: `src/GameTrainer.Core/Catalog/CatalogStore.cs`)
- Dashboard view model → Catalog and run store: reads run data (evidence: `src/GameTrainer.Gui/DashboardViewModel.cs`)
- Dashboard view model → Game descriptors: uses game metadata (evidence: `src/GameTrainer.Gui/DashboardViewModel.cs`)
- GUI application → Observatory window: opens window (evidence: `src/GameTrainer.Gui/App.cs`)
- Observatory window → Dashboard view model: presents data (evidence: `src/GameTrainer.Gui/MainWindow.cs`)
- Observatory window → Improvement chart: renders metrics (evidence: `src/GameTrainer.Gui/MainWindow.cs`)
- Observatory window → Classic theme: applies styling (evidence: `src/GameTrainer.Gui/MainWindow.cs`)
- Improvement chart → Classic theme: uses styling (evidence: `src/GameTrainer.Gui/ImprovementChartControl.cs`)
