# seongilheo/ucmarl architecture

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

- Interactive diagram: https://gitdiagram.com/seongilheo/ucmarl
- Repository: https://github.com/seongilheo/ucmarl

## Overview

UCMARL is an experimental cooperative multi-agent reinforcement-learning system centered on communication-aware PPO. Its main workflow is CLI selection, algorithm-specific runner execution, vectorized environment interaction, rollout collection and policy updates, with evaluation/rendering and logged outputs. The README documents these runtime stages and the supported algorithm families; sampled source confirms a runner’s environment/algorithm wiring and supporting rollout/network components. Unsampled runner and algorithm internals are represented at their exact directories, so their finer-grained calls are not inferred.

Main entry points: [`runners`](https://github.com/seongilheo/ucmarl/tree/main/runners) (Mode runners), [`envs/env_factory.py`](https://github.com/seongilheo/ucmarl/blob/main/envs/env_factory.py) (Environment factory), [`envs/env_vectorization.py`](https://github.com/seongilheo/ucmarl/blob/main/envs/env_vectorization.py) (Vector environments), [`train.py`](https://github.com/seongilheo/ucmarl/blob/main/train.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run orchestration"]
  node_cli["CLI entry<br/>[train.py]"]
  node_runners["Mode runners"]
  node_logging["Run logging<br/>[logger.py]"]
  node_evaluation["Evaluation tools"]
  node_rendering["Video rendering<br/>[video_utils.py]"]
end

subgraph group_methods["RL methods"]
  node_ucmappo["UCMAPPO"]
  node_mappo["MAPPO"]
  node_communication["Communication baselines"]
  node_advanced["Advanced PPO variants"]
  node_mamba["MAMBA world model<br/>[mamba.py]"]
  node_storage["Rollout storage<br/>[rollout_storage.py]"]
end

subgraph group_world["Environment runtime"]
  node_envfactory["Environment factory<br/>[env_factory.py]"]
  node_vectorenv["Vector environments"]
  node_pogema["POGEMA adapter<br/>[pogema_env.py]"]
  node_mpe["MPE2 adapter<br/>[mpe_env.py]"]
  node_wrappers["Environment wrappers<br/>[base_wrapper.py]"]
end

subgraph group_support["Learning support"]
  node_nets["Shared networks<br/>[mlp.py]"]
  node_metrics["POGEMA metrics<br/>[pogema_metrics.py]"]
  node_normalization["Reward normalization"]
  node_transforms["Tensor transforms<br/>[transform_tools.py]"]
end

node_operator(("Experimenter"))
node_externalenv["POGEMA / MPE2"]
node_runoutputs[("Run artifacts")]
node_wandb["Weights &amp; Biases"]

node_operator -->|"starts run"| node_cli
node_cli -->|"selects runner"| node_runners
node_runners -->|"runs algorithm"| node_ucmappo
node_runners -->|"runs algorithm"| node_mappo
node_runners -->|"runs algorithm"| node_communication
node_runners -->|"runs algorithm"| node_advanced
node_runners -->|"runs algorithm"| node_mamba
node_runners -->|"creates environments"| node_envfactory
node_envfactory -.->|"constructs"| node_vectorenv
node_vectorenv -.->|"dispatches to"| node_pogema
node_vectorenv -.->|"dispatches to"| node_mpe
node_pogema -->|"wraps"| node_externalenv
node_mpe -->|"supports"| node_externalenv
node_envfactory -.->|"uses wrappers"| node_wrappers
node_runners -.->|"stores rollout"| node_storage
node_storage -->|"converts batches"| node_transforms
node_ucmappo -->|"uses networks"| node_nets
node_runners -->|"logs run"| node_logging
node_runners -->|"records metrics"| node_metrics
node_runners -->|"normalizes rewards"| node_normalization
node_runners -->|"saves videos"| node_rendering
node_operator -->|"analyzes runs"| node_evaluation
node_evaluation -->|"reads results"| node_runoutputs
node_logging -->|"writes logs"| node_runoutputs
node_runners -.->|"tracks experiments"| node_wandb

click node_cli "https://github.com/seongilheo/ucmarl/blob/main/train.py"
click node_runners "https://github.com/seongilheo/ucmarl/tree/main/runners"
click node_logging "https://github.com/seongilheo/ucmarl/blob/main/utils/logger.py"
click node_evaluation "https://github.com/seongilheo/ucmarl/tree/main/tools"
click node_rendering "https://github.com/seongilheo/ucmarl/blob/main/utils/video_utils.py"
click node_ucmappo "https://github.com/seongilheo/ucmarl/tree/main/algos/ucmappo"
click node_mappo "https://github.com/seongilheo/ucmarl/tree/main/algos/mappo"
click node_communication "https://github.com/seongilheo/ucmarl/tree/main/algos"
click node_advanced "https://github.com/seongilheo/ucmarl/tree/main/algos"
click node_mamba "https://github.com/seongilheo/ucmarl/blob/main/algos/mamba/mamba.py"
click node_storage "https://github.com/seongilheo/ucmarl/blob/main/algos/ucmappo/rollout_storage.py"
click node_envfactory "https://github.com/seongilheo/ucmarl/blob/main/envs/env_factory.py"
click node_vectorenv "https://github.com/seongilheo/ucmarl/blob/main/envs/env_vectorization.py"
click node_pogema "https://github.com/seongilheo/ucmarl/blob/main/envs/pogema/pogema_env.py"
click node_mpe "https://github.com/seongilheo/ucmarl/blob/main/envs/mpe2/mpe_env.py"
click node_wrappers "https://github.com/seongilheo/ucmarl/blob/main/envs/wrappers/base_wrapper.py"
click node_nets "https://github.com/seongilheo/ucmarl/blob/main/networks/mlp.py"
click node_metrics "https://github.com/seongilheo/ucmarl/blob/main/utils/pogema_metrics.py"
click node_normalization "https://github.com/seongilheo/ucmarl/blob/main/utils/reward_normalization.py"
click node_transforms "https://github.com/seongilheo/ucmarl/blob/main/utils/transform_tools.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_cli,node_runners,node_logging,node_evaluation,node_rendering toneBlue
class node_ucmappo,node_mappo,node_communication,node_advanced,node_mamba,node_storage,node_runoutputs toneAmber
class node_envfactory,node_vectorenv,node_pogema,node_mpe,node_wrappers toneMint
class node_nets,node_metrics,node_normalization,node_transforms toneRose
class node_operator,node_externalenv,node_wandb toneIndigo
```

## Components

### Run orchestration

- [CLI entry](https://github.com/seongilheo/ucmarl/blob/main/train.py): `train.py`
- [Mode runners](https://github.com/seongilheo/ucmarl/tree/main/runners): `runners`
- [Run logging](https://github.com/seongilheo/ucmarl/blob/main/utils/logger.py): `utils/logger.py`
- [Evaluation tools](https://github.com/seongilheo/ucmarl/tree/main/tools): `tools`
- [Video rendering](https://github.com/seongilheo/ucmarl/blob/main/utils/video_utils.py): `utils/video_utils.py`

### RL methods

- [UCMAPPO](https://github.com/seongilheo/ucmarl/tree/main/algos/ucmappo): `algos/ucmappo`
- [MAPPO](https://github.com/seongilheo/ucmarl/tree/main/algos/mappo): `algos/mappo`
- [Communication baselines](https://github.com/seongilheo/ucmarl/tree/main/algos): `algos`
- [Advanced PPO variants](https://github.com/seongilheo/ucmarl/tree/main/algos): `algos`
- [MAMBA world model](https://github.com/seongilheo/ucmarl/blob/main/algos/mamba/mamba.py): `algos/mamba/mamba.py`
- [Rollout storage](https://github.com/seongilheo/ucmarl/blob/main/algos/ucmappo/rollout_storage.py): `algos/ucmappo/rollout_storage.py`

### Environment runtime

- [Environment factory](https://github.com/seongilheo/ucmarl/blob/main/envs/env_factory.py): `envs/env_factory.py`
- [Vector environments](https://github.com/seongilheo/ucmarl/blob/main/envs/env_vectorization.py): `envs/env_vectorization.py`
- [POGEMA adapter](https://github.com/seongilheo/ucmarl/blob/main/envs/pogema/pogema_env.py): `envs/pogema/pogema_env.py`
- [MPE2 adapter](https://github.com/seongilheo/ucmarl/blob/main/envs/mpe2/mpe_env.py): `envs/mpe2/mpe_env.py`
- [Environment wrappers](https://github.com/seongilheo/ucmarl/blob/main/envs/wrappers/base_wrapper.py): `envs/wrappers/base_wrapper.py`

### Learning support

- [Shared networks](https://github.com/seongilheo/ucmarl/blob/main/networks/mlp.py): `networks/mlp.py`
- [POGEMA metrics](https://github.com/seongilheo/ucmarl/blob/main/utils/pogema_metrics.py): `utils/pogema_metrics.py`
- [Reward normalization](https://github.com/seongilheo/ucmarl/blob/main/utils/reward_normalization.py): `utils/reward_normalization.py`
- [Tensor transforms](https://github.com/seongilheo/ucmarl/blob/main/utils/transform_tools.py): `utils/transform_tools.py`

### Other components

- **Experimenter**
- **POGEMA / MPE2**
- **Run artifacts**
- **Weights & Biases**

## Connections

- Experimenter → CLI entry: starts run (evidence: `README.md`)
- CLI entry → Mode runners: selects runner (evidence: `README.md`)
- Mode runners → UCMAPPO: runs algorithm (evidence: `README.md`)
- Mode runners → MAPPO: runs algorithm (evidence: `README.md`)
- Mode runners → Communication baselines: runs algorithm (evidence: `README.md`)
- Mode runners → Advanced PPO variants: runs algorithm (evidence: `README.md`)
- Mode runners → MAMBA world model: runs algorithm (evidence: `README.md`)
- Mode runners → Environment factory: creates environments (evidence: `runners/pdgppo_runner.py`)
- Environment factory → Vector environments: constructs
- Vector environments → POGEMA adapter: dispatches to
- Vector environments → MPE2 adapter: dispatches to
- POGEMA adapter → POGEMA / MPE2: wraps (evidence: `README.md`)
- MPE2 adapter → POGEMA / MPE2: supports (evidence: `README.md`)
- Environment factory → Environment wrappers: uses wrappers
- Mode runners → Rollout storage: stores rollout
- Rollout storage → Tensor transforms: converts batches (evidence: `algos/ucmappo/rollout_storage.py`)
- UCMAPPO → Shared networks: uses networks (evidence: `algos/ucmappo/networks.py`)
- Mode runners → Run logging: logs run (evidence: `README.md`)
- Mode runners → POGEMA metrics: records metrics (evidence: `runners/pdgppo_runner.py`)
- Mode runners → Reward normalization: normalizes rewards (evidence: `README.md`)
- Mode runners → Video rendering: saves videos (evidence: `README.md`)
- Experimenter → Evaluation tools: analyzes runs (evidence: `README.md`)
- Evaluation tools → Run artifacts: reads results (evidence: `README.md`)
- Run logging → Run artifacts: writes logs (evidence: `README.md`)
- Mode runners → Weights & Biases: tracks experiments (evidence: `README.md`)
