# driw0x/kaggriculture architecture

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

- Interactive diagram: https://gitdiagram.com/driw0x/kaggriculture
- Repository: https://github.com/driw0x/kaggriculture

## Overview

Kaggriculture develops autonomous farm-strategy agents for Kaggle. The main workflow is an observation from the game environment entering an agent, which returns market and worker actions for the environment to apply; the next turn supplies updated state. The repository also develops heuristic-agent families and a behavioral-cloning path from replay data through state/target encoding and model inference. The excerpts show the Jet agent’s observation-driven routing and policy decoding, but do not establish wiring among the broader agent variants or unsampled training modules.

Main entry points: [`src/learning/policy.py`](https://github.com/driw0x/kaggriculture/blob/master/src/learning/policy.py) (BC policy), [`src/learning/bc_dataset.py`](https://github.com/driw0x/kaggriculture/blob/master/src/learning/bc_dataset.py) (BC dataset), [`src/learning/replay_dataset.py`](https://github.com/driw0x/kaggriculture/blob/master/src/learning/replay_dataset.py) (Replay dataset), [`src/agents/jet6.py`](https://github.com/driw0x/kaggriculture/blob/master/src/agents/jet6.py) (Jet agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Game interaction"]
  node_game(("Kaggriculture environment"))
  node_observation["Game observation"]
  node_actions["Farm actions"]
end

subgraph group_agents["Agent strategies"]
  node_jet["Jet agent<br/>[jet6.py]"]
  node_chi["CHI planners<br/>[chi.py]"]
  node_ye["Ye agents<br/>[ye.py]"]
  node_agent_interface["Agent interface<br/>[agent.py]"]
  node_submission["Kaggle submission<br/>[agent.py]"]
end

subgraph group_learning["Behavioral cloning"]
  node_bc_agent["BC agent<br/>[bc_agent.py]"]
  node_policy["BC policy<br/>[policy.py]"]
  node_model["BC model<br/>[model.py]"]
  node_state_encoder["State encoder<br/>[state_encoder.py]"]
  node_target_encoder["Target encoder<br/>[target_encoder.py]"]
end

subgraph group_replay["Replay learning"]
  node_replay_dataset["Replay dataset<br/>[replay_dataset.py]"]
  node_decision_extractor["Decision extractor"]
  node_bc_dataset["BC dataset<br/>[bc_dataset.py]"]
  node_preencoded_dataset["Preencoded dataset"]
end

node_game -->|"provides"| node_observation
node_observation -->|"supplies state"| node_jet
node_jet -->|"returns actions"| node_actions
node_actions -->|"applies turn"| node_game
node_observation -->|"supplies state"| node_chi
node_chi -->|"returns actions"| node_actions
node_observation -->|"supplies state"| node_ye
node_ye -->|"returns actions"| node_actions
node_observation -->|"supplies state"| node_bc_agent
node_bc_agent -->|"requests action"| node_policy
node_policy -->|"encodes state"| node_state_encoder
node_policy -->|"runs inference"| node_model
node_policy -->|"decodes output"| node_target_encoder
node_replay_dataset -->|"provides examples"| node_bc_dataset
node_replay_dataset -->|"extracts actions"| node_decision_extractor
node_bc_dataset -->|"encodes states"| node_state_encoder
node_bc_dataset -->|"encodes targets"| node_target_encoder
node_preencoded_dataset -.->|"provides encoded data"| node_bc_dataset
node_submission -.->|"submits agent"| node_game

click node_jet "https://github.com/driw0x/kaggriculture/blob/master/src/agents/jet6.py"
click node_chi "https://github.com/driw0x/kaggriculture/blob/master/src/agents/chi.py"
click node_ye "https://github.com/driw0x/kaggriculture/blob/master/src/agents/ye.py"
click node_agent_interface "https://github.com/driw0x/kaggriculture/blob/master/src/agents/agent.py"
click node_submission "https://github.com/driw0x/kaggriculture/blob/master/submissions/agent.py"
click node_bc_agent "https://github.com/driw0x/kaggriculture/blob/master/src/agents/bc_agent.py"
click node_policy "https://github.com/driw0x/kaggriculture/blob/master/src/learning/policy.py"
click node_model "https://github.com/driw0x/kaggriculture/blob/master/src/learning/model.py"
click node_state_encoder "https://github.com/driw0x/kaggriculture/blob/master/src/learning/state_encoder.py"
click node_target_encoder "https://github.com/driw0x/kaggriculture/blob/master/src/learning/target_encoder.py"
click node_replay_dataset "https://github.com/driw0x/kaggriculture/blob/master/src/learning/replay_dataset.py"
click node_decision_extractor "https://github.com/driw0x/kaggriculture/blob/master/src/learning/decision_extractor.py"
click node_bc_dataset "https://github.com/driw0x/kaggriculture/blob/master/src/learning/bc_dataset.py"
click node_preencoded_dataset "https://github.com/driw0x/kaggriculture/blob/master/src/learning/preencoded_dataset.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_observation,node_actions toneBlue
class node_jet,node_chi,node_ye,node_agent_interface,node_submission toneAmber
class node_bc_agent,node_policy,node_model,node_state_encoder,node_target_encoder toneMint
class node_replay_dataset,node_decision_extractor,node_bc_dataset,node_preencoded_dataset toneRose
```

## Components

### Game interaction

- **Kaggriculture environment**
- **Game observation**
- **Farm actions**

### Agent strategies

- [Jet agent](https://github.com/driw0x/kaggriculture/blob/master/src/agents/jet6.py): `src/agents/jet6.py`
- [CHI planners](https://github.com/driw0x/kaggriculture/blob/master/src/agents/chi.py): `src/agents/chi.py`
- [Ye agents](https://github.com/driw0x/kaggriculture/blob/master/src/agents/ye.py): `src/agents/ye.py`
- [Agent interface](https://github.com/driw0x/kaggriculture/blob/master/src/agents/agent.py): `src/agents/agent.py`
- [Kaggle submission](https://github.com/driw0x/kaggriculture/blob/master/submissions/agent.py): `submissions/agent.py`

### Behavioral cloning

- [BC agent](https://github.com/driw0x/kaggriculture/blob/master/src/agents/bc_agent.py): `src/agents/bc_agent.py`
- [BC policy](https://github.com/driw0x/kaggriculture/blob/master/src/learning/policy.py): `src/learning/policy.py`
- [BC model](https://github.com/driw0x/kaggriculture/blob/master/src/learning/model.py): `src/learning/model.py`
- [State encoder](https://github.com/driw0x/kaggriculture/blob/master/src/learning/state_encoder.py): `src/learning/state_encoder.py`
- [Target encoder](https://github.com/driw0x/kaggriculture/blob/master/src/learning/target_encoder.py): `src/learning/target_encoder.py`

### Replay learning

- [Replay dataset](https://github.com/driw0x/kaggriculture/blob/master/src/learning/replay_dataset.py): `src/learning/replay_dataset.py`
- [Decision extractor](https://github.com/driw0x/kaggriculture/blob/master/src/learning/decision_extractor.py): `src/learning/decision_extractor.py`
- [BC dataset](https://github.com/driw0x/kaggriculture/blob/master/src/learning/bc_dataset.py): `src/learning/bc_dataset.py`
- [Preencoded dataset](https://github.com/driw0x/kaggriculture/blob/master/src/learning/preencoded_dataset.py): `src/learning/preencoded_dataset.py`

## Connections

- Kaggriculture environment → Game observation: provides
- Game observation → Jet agent: supplies state
- Jet agent → Farm actions: returns actions
- Farm actions → Kaggriculture environment: applies turn
- Game observation → CHI planners: supplies state
- CHI planners → Farm actions: returns actions
- Game observation → Ye agents: supplies state
- Ye agents → Farm actions: returns actions
- Game observation → BC agent: supplies state
- BC agent → BC policy: requests action
- BC policy → State encoder: encodes state
- BC policy → BC model: runs inference
- BC policy → Target encoder: decodes output
- Replay dataset → BC dataset: provides examples
- Replay dataset → Decision extractor: extracts actions
- BC dataset → State encoder: encodes states
- BC dataset → Target encoder: encodes targets
- Preencoded dataset → BC dataset: provides encoded data
- Kaggle submission → Kaggriculture environment: submits agent
