# based-watermelon/barrel-ly-learning architecture

> Architecture diagram of the GitHub repository based-watermelon/barrel-ly-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/based-watermelon/barrel-ly-learning
- Repository: https://github.com/based-watermelon/barrel-ly-learning

## Overview

This repository combines a playable Donkey Kong environment with imitation-learning autoplay and an actor-critic model. The main runtime loop gathers game state, obtains actions from the behavior-cloning policy in autoplay mode, and advances and renders the game. The documented training workflow uses gameplay demonstrations to train that policy; actor-critic is a separate model component. The README and tree establish these capabilities, but the training notebook and RL experiment source were not sampled, so their internal wiring is not inferred.

Main entry points: [`environment/lfdautoplay.py`](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/lfdautoplay.py) (Donkey Kong game), [`model/bc_policy.pt`](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/bc_policy.pt) (Trained BC model), [`model/lfdmodel.ipynb`](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/lfdmodel.ipynb) (BC training), [`model/actor_critic.py`](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/actor_critic.py) (Actor-critic model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game runtime"]
  node_game["Donkey Kong game<br/>[lfdautoplay.py]"]
  node_features["State features"]
end

subgraph group_imitation["Imitation learning"]
  node_bc_train["BC training<br/>[lfdmodel.ipynb]"]
  node_bc_model["Trained BC model<br/>[bc_policy.pt]"]
  node_bc_policy["BC policy<br/>[lfdautoplay.py]"]
end

subgraph group_data["Demonstration data"]
  node_dataset[("Gameplay dataset")]
  node_csvmerge["CSV merger<br/>[csvmerger.py]"]
end

subgraph group_rl["Reinforcement learning"]
  node_actor_critic["Actor-critic model<br/>[actor_critic.py]"]
  node_rl_test["RL experiment<br/>[rl_test.py]"]
end

node_player(("Player"))

node_player -->|"plays"| node_game
node_game -->|"extracts state"| node_features
node_dataset -->|"trains from"| node_bc_train
node_bc_train -->|"produces"| node_bc_model
node_game -->|"loads weights"| node_bc_model
node_actor_critic -->|"loads BC weights"| node_bc_model

click node_game "https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/lfdautoplay.py"
click node_features "https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/feature_extraction.py"
click node_csvmerge "https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/csvmerger.py"
click node_bc_train "https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/lfdmodel.ipynb"
click node_bc_model "https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/bc_policy.pt"
click node_bc_policy "https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/lfdautoplay.py"
click node_actor_critic "https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/actor_critic.py"
click node_rl_test "https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/rl_test.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_game,node_features toneBlue
class node_bc_train,node_bc_model,node_bc_policy toneAmber
class node_dataset,node_csvmerge toneMint
class node_actor_critic,node_rl_test toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Donkey Kong game](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/lfdautoplay.py): `environment/lfdautoplay.py`
- [State features](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/feature_extraction.py): `environment/feature_extraction.py`

### Imitation learning

- [BC training](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/lfdmodel.ipynb): `model/lfdmodel.ipynb`
- [Trained BC model](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/bc_policy.pt): `model/bc_policy.pt`
- [BC policy](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/lfdautoplay.py): `environment/lfdautoplay.py`

### Demonstration data

- **Gameplay dataset**
- [CSV merger](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/csvmerger.py): `environment/csvmerger.py`

### Reinforcement learning

- [Actor-critic model](https://github.com/based-watermelon/barrel-ly-learning/blob/main/model/actor_critic.py): `model/actor_critic.py`
- [RL experiment](https://github.com/based-watermelon/barrel-ly-learning/blob/main/environment/rl_test.py): `environment/rl_test.py`

### Other components

- **Player**

## Connections

- Player → Donkey Kong game: plays
- Donkey Kong game → State features: extracts state
- Gameplay dataset → BC training: trains from
- BC training → Trained BC model: produces
- Donkey Kong game → Trained BC model: loads weights
- Actor-critic model → Trained BC model: loads BC weights
