# assassin29092005/game_rl architecture

> Architecture diagram of the GitHub repository assassin29092005/game_rl, 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/assassin29092005/game_rl
- Repository: https://github.com/assassin29092005/game_rl

## Overview

HellwalkerRL is an Unreal action game whose adaptive keeper uses a recurrent policy trained offline, with the same engine-free combat core used by simulators. The main player flow is input through the game controller into a duel; the keeper chooses scripted or adaptive actions, and session state preserves its learning across shrine fights. The repository also includes training/evaluation tools and a research website for player statistics. Several subsystem links are based on README or SOURCE INDEX references rather than inspected implementations, so only documented or indexed relationships are shown.

Main entry points: [`web/js/app.js`](https://github.com/assassin29092005/game_rl/blob/main/web/js/app.js) (Site Router), [`RL/train.py`](https://github.com/assassin29092005/game_rl/blob/main/RL/train.py) (PPO Trainer), [`Source/HellwalkerRL/Private/HWPlayerController.cpp`](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWPlayerController.cpp) (Input & Menus), [`Source/HellwalkerRL/Private/HWDuelSubsystem.cpp`](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWDuelSubsystem.cpp) (Duel Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Unreal Game"]
  node_controller["Input &amp; Menus"]
  node_menu["Menu Builder"]
  node_openworld["Open World"]
  node_duel["Duel Runtime"]
  node_session["Keeper Session"]
  node_settings["Settings<br/>[HWSettings.cpp]"]
end

subgraph group_core["Combat Core"]
  node_combat["Combat Rules<br/>[HWDuel.cpp]"]
  node_simcore["Encounter Simulator<br/>[HWSim.cpp]"]
  node_scriptbrain["Scripted Keeper<br/>[HWScriptBrain.cpp]"]
  node_rlbrain["Adaptive Keeper<br/>[HWRLBrain.cpp]"]
  node_observer["Player Observer<br/>[HWRLObserver.cpp]"]
end

subgraph group_learning["RL Training"]
  node_model["Recurrent Policy<br/>[model.py]"]
  node_environment["Training Environment<br/>[env.py]"]
  node_trainer["PPO Trainer<br/>[train.py]"]
  node_export["Policy Export<br/>[export.py]"]
  node_habit["Habit Profiles<br/>[habits.py]"]
  node_players["Simulated Players<br/>[players.py]"]
end

subgraph group_sim["Simulation Tools"]
  node_classic["Classic Benchmark<br/>[HWClassicBrain.cpp]"]
  node_arms["Comparison Arms<br/>[SimArms.cpp]"]
  node_thesis["Thesis Simulator<br/>[ThesisSim.cpp]"]
end

subgraph group_site["Research Website"]
  node_webapp["Site Router<br/>[app.js]"]
  node_webapi["Remote Backend<br/>[api.js]"]
  node_demodata["Demo Backend<br/>[demo.js]"]
  node_profile["Player Profile<br/>[profile.js]"]
  node_leaderboard["Leaderboard<br/>[leaderboard.js]"]
  node_research["Research Info<br/>[research.js]"]
end

node_player(("Player"))
node_firebase[("Firebase")]

node_player -->|"sends input"| node_controller
node_controller -->|"queues actions"| node_duel
node_controller -->|"controls exploration"| node_openworld
node_controller -->|"builds menus"| node_menu
node_duel -.->|"runs encounter"| node_combat
node_duel -->|"dispatches keeper"| node_rlbrain
node_duel -->|"dispatches keeper"| node_scriptbrain
node_session -->|"provides memory"| node_rlbrain
node_rlbrain -->|"observes player"| node_observer
node_trainer -->|"trains against"| node_environment
node_trainer -->|"optimizes"| node_model
node_trainer -->|"exports policy"| node_export
node_trainer -->|"uses profiles"| node_habit
node_environment -->|"simulates players"| node_players
node_environment -->|"calls core"| node_simcore
node_export -->|"serializes"| node_model
node_session -.->|"loads trained weights"| node_export
node_thesis -->|"compares arms"| node_arms
node_arms -->|"runs benchmark"| node_classic
node_arms -->|"runs adaptive arm"| node_rlbrain
node_webapp -->|"selects backend"| node_webapi
node_webapp -->|"selects backend"| node_demodata
node_webapp -->|"routes to"| node_profile
node_webapp -->|"routes to"| node_leaderboard
node_webapp -->|"routes to"| node_research
node_webapi -.->|"reads and writes"| node_firebase
node_profile -.->|"loads player data"| node_webapi

click node_controller "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWPlayerController.cpp"
click node_menu "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWPlayerControllerMenu.cpp"
click node_openworld "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWOpenWorldGameMode.cpp"
click node_duel "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWDuelSubsystem.cpp"
click node_session "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWSessionSubsystem.cpp"
click node_settings "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWSettings.cpp"
click node_combat "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWDuel.cpp"
click node_simcore "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWSim.cpp"
click node_scriptbrain "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWScriptBrain.cpp"
click node_rlbrain "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWRLBrain.cpp"
click node_observer "https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWRLObserver.cpp"
click node_model "https://github.com/assassin29092005/game_rl/blob/main/RL/model.py"
click node_environment "https://github.com/assassin29092005/game_rl/blob/main/RL/env.py"
click node_trainer "https://github.com/assassin29092005/game_rl/blob/main/RL/train.py"
click node_export "https://github.com/assassin29092005/game_rl/blob/main/RL/export.py"
click node_habit "https://github.com/assassin29092005/game_rl/blob/main/RL/habits.py"
click node_players "https://github.com/assassin29092005/game_rl/blob/main/RL/players.py"
click node_classic "https://github.com/assassin29092005/game_rl/blob/main/Sim/Classic/HWClassicBrain.cpp"
click node_arms "https://github.com/assassin29092005/game_rl/blob/main/Sim/SimArms.cpp"
click node_thesis "https://github.com/assassin29092005/game_rl/blob/main/Sim/ThesisSim.cpp"
click node_webapp "https://github.com/assassin29092005/game_rl/blob/main/web/js/app.js"
click node_webapi "https://github.com/assassin29092005/game_rl/blob/main/web/js/api.js"
click node_demodata "https://github.com/assassin29092005/game_rl/blob/main/web/js/demo.js"
click node_profile "https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/profile.js"
click node_leaderboard "https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/leaderboard.js"
click node_research "https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/research.js"

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_controller,node_menu,node_openworld,node_duel,node_session,node_settings toneBlue
class node_combat,node_simcore,node_scriptbrain,node_rlbrain,node_observer,node_firebase toneAmber
class node_model,node_environment,node_trainer,node_export,node_habit,node_players toneMint
class node_classic,node_arms,node_thesis toneRose
class node_webapp,node_webapi,node_demodata,node_profile,node_leaderboard,node_research,node_player toneIndigo
```

## Components

### Unreal Game

- [Input & Menus](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWPlayerController.cpp): `Source/HellwalkerRL/Private/HWPlayerController.cpp`
- [Menu Builder](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWPlayerControllerMenu.cpp): `Source/HellwalkerRL/Private/HWPlayerControllerMenu.cpp`
- [Open World](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWOpenWorldGameMode.cpp): `Source/HellwalkerRL/Private/HWOpenWorldGameMode.cpp`
- [Duel Runtime](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWDuelSubsystem.cpp): `Source/HellwalkerRL/Private/HWDuelSubsystem.cpp`
- [Keeper Session](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWSessionSubsystem.cpp): `Source/HellwalkerRL/Private/HWSessionSubsystem.cpp`
- [Settings](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWSettings.cpp): `Source/HellwalkerRL/Private/HWSettings.cpp`

### Combat Core

- [Combat Rules](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWDuel.cpp): `Source/HellwalkerRL/Private/HWCore/HWDuel.cpp`
- [Encounter Simulator](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWSim.cpp): `Source/HellwalkerRL/Private/HWCore/HWSim.cpp`
- [Scripted Keeper](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWScriptBrain.cpp): `Source/HellwalkerRL/Private/HWCore/HWScriptBrain.cpp`
- [Adaptive Keeper](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWRLBrain.cpp): `Source/HellwalkerRL/Private/HWCore/HWRLBrain.cpp`
- [Player Observer](https://github.com/assassin29092005/game_rl/blob/main/Source/HellwalkerRL/Private/HWCore/HWRLObserver.cpp): `Source/HellwalkerRL/Private/HWCore/HWRLObserver.cpp`

### RL Training

- [Recurrent Policy](https://github.com/assassin29092005/game_rl/blob/main/RL/model.py): `RL/model.py`
- [Training Environment](https://github.com/assassin29092005/game_rl/blob/main/RL/env.py): `RL/env.py`
- [PPO Trainer](https://github.com/assassin29092005/game_rl/blob/main/RL/train.py): `RL/train.py`
- [Policy Export](https://github.com/assassin29092005/game_rl/blob/main/RL/export.py): `RL/export.py`
- [Habit Profiles](https://github.com/assassin29092005/game_rl/blob/main/RL/habits.py): `RL/habits.py`
- [Simulated Players](https://github.com/assassin29092005/game_rl/blob/main/RL/players.py): `RL/players.py`

### Simulation Tools

- [Classic Benchmark](https://github.com/assassin29092005/game_rl/blob/main/Sim/Classic/HWClassicBrain.cpp): `Sim/Classic/HWClassicBrain.cpp`
- [Comparison Arms](https://github.com/assassin29092005/game_rl/blob/main/Sim/SimArms.cpp): `Sim/SimArms.cpp`
- [Thesis Simulator](https://github.com/assassin29092005/game_rl/blob/main/Sim/ThesisSim.cpp): `Sim/ThesisSim.cpp`

### Research Website

- [Site Router](https://github.com/assassin29092005/game_rl/blob/main/web/js/app.js): `web/js/app.js`
- [Remote Backend](https://github.com/assassin29092005/game_rl/blob/main/web/js/api.js): `web/js/api.js`
- [Demo Backend](https://github.com/assassin29092005/game_rl/blob/main/web/js/demo.js): `web/js/demo.js`
- [Player Profile](https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/profile.js): `web/js/pages/profile.js`
- [Leaderboard](https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/leaderboard.js): `web/js/pages/leaderboard.js`
- [Research Info](https://github.com/assassin29092005/game_rl/blob/main/web/js/pages/research.js): `web/js/pages/research.js`

### Other components

- **Player**
- **Firebase**

## Connections

- Player → Input & Menus: sends input
- Input & Menus → Duel Runtime: queues actions (evidence: `Source/HellwalkerRL/Private/HWPlayerController.cpp`)
- Input & Menus → Open World: controls exploration (evidence: `Source/HellwalkerRL/Private/HWPlayerController.cpp`)
- Input & Menus → Menu Builder: builds menus (evidence: `Source/HellwalkerRL/Private/HWPlayerControllerMenu.cpp`)
- Duel Runtime → Combat Rules: runs encounter
- Duel Runtime → Adaptive Keeper: dispatches keeper
- Duel Runtime → Scripted Keeper: dispatches keeper
- Keeper Session → Adaptive Keeper: provides memory
- Adaptive Keeper → Player Observer: observes player
- PPO Trainer → Training Environment: trains against (evidence: `RL/train.py`)
- PPO Trainer → Recurrent Policy: optimizes (evidence: `RL/train.py`)
- PPO Trainer → Policy Export: exports policy (evidence: `RL/train.py`)
- PPO Trainer → Habit Profiles: uses profiles (evidence: `RL/train.py`)
- Training Environment → Simulated Players: simulates players (evidence: `RL/env.py`)
- Training Environment → Encounter Simulator: calls core (evidence: `RL/env.py`)
- Policy Export → Recurrent Policy: serializes (evidence: `RL/export.py`)
- Keeper Session → Policy Export: loads trained weights
- Thesis Simulator → Comparison Arms: compares arms (evidence: `Sim/ThesisSim.cpp`)
- Comparison Arms → Classic Benchmark: runs benchmark (evidence: `Sim/SimArms.cpp`)
- Comparison Arms → Adaptive Keeper: runs adaptive arm (evidence: `Sim/SimArms.cpp`)
- Site Router → Remote Backend: selects backend (evidence: `web/js/app.js`)
- Site Router → Demo Backend: selects backend (evidence: `web/js/app.js`)
- Site Router → Player Profile: routes to (evidence: `web/js/app.js`)
- Site Router → Leaderboard: routes to (evidence: `web/js/app.js`)
- Site Router → Research Info: routes to (evidence: `web/js/app.js`)
- Remote Backend → Firebase: reads and writes
- Player Profile → Remote Backend: loads player data
