# jaypatil9/hexapawnrl architecture

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

- Interactive diagram: https://gitdiagram.com/jaypatil9/hexapawnrl
- Repository: https://github.com/jaypatil9/hexapawnrl

## Overview

HexapawnRL provides a playable Hexapawn game plus three AI approaches: HER and HIM learn move preferences through self-play, while brute force enumerates game outcomes. A typical user plays through a game module, which handles board interaction and requests AI moves when configured. The learner trainers update their strategy data; agents consult that data to select moves. The root game is a separate human-vs-human implementation. Some algorithm game and utility wiring is inferred only where the sampled excerpts show imports or calls; unsampled behavior and generated solver-table paths are omitted.

Main entry points: [`brute_force/game.py`](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/game.py) (Solver game), [`brute_force/utils.py`](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/utils.py) (Solver rules), [`HER/game.py`](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/game.py) (HER game), [`HIM/game.py`](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/game.py) (HIM game)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game play"]
  node_rootgame["Standalone game<br/>[game.py]"]
  node_hergame["HER game<br/>[game.py]"]
  node_himgame["HIM game<br/>[game.py]"]
  node_bfgame["Solver game<br/>[game.py]"]
end

subgraph group_learn["Learning agents"]
  node_heragent["HER agent<br/>[agent.py]"]
  node_hertrainer["HER trainer<br/>[train.py]"]
  node_herutils["HER rules<br/>[utils.py]"]
  node_herstates["HER seed states<br/>[states.txt]"]
  node_himagent["HIM agent<br/>[agent.py]"]
  node_himtrainer["HIM trainer<br/>[train.py]"]
  node_himutils["HIM rules<br/>[utils.py]"]
  node_himstates["HIM seed states<br/>[states.txt]"]
end

subgraph group_solver["Brute-force solver"]
  node_bfagent["Solver agent<br/>[agent.py]"]
  node_bfsearch["Game-tree search<br/>[train.py]"]
  node_bfutils["Solver rules<br/>[utils.py]"]
end

node_human(("Human player"))

node_human -->|"plays through"| node_rootgame
node_human -->|"plays through"| node_hergame
node_human -->|"plays through"| node_himgame
node_human -->|"plays through"| node_bfgame
node_hergame -->|"requests moves"| node_heragent
node_himgame -->|"requests moves"| node_himagent
node_bfgame -->|"requests moves"| node_bfagent
node_hergame -->|"checks rules"| node_herutils
node_himgame -->|"checks rules"| node_himutils
node_bfgame -->|"checks rules"| node_bfutils
node_heragent -->|"encodes states"| node_herutils
node_heragent -->|"trains if needed"| node_hertrainer
node_hertrainer -->|"loads seed data"| node_herstates
node_hertrainer -->|"uses rules"| node_herutils
node_himagent -->|"encodes states"| node_himutils
node_himagent -->|"trains if needed"| node_himtrainer
node_himtrainer -->|"loads seed data"| node_himstates
node_himtrainer -->|"uses rules"| node_himutils
node_bfagent -->|"selects legal moves"| node_bfutils
node_bfsearch -->|"enumerates moves"| node_bfutils
node_bfgame -->|"configures agent rules"| node_bfutils

click node_rootgame "https://github.com/jaypatil9/hexapawnrl/blob/main/game.py"
click node_hergame "https://github.com/jaypatil9/hexapawnrl/blob/main/HER/game.py"
click node_himgame "https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/game.py"
click node_bfgame "https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/game.py"
click node_heragent "https://github.com/jaypatil9/hexapawnrl/blob/main/HER/agent.py"
click node_hertrainer "https://github.com/jaypatil9/hexapawnrl/blob/main/HER/train.py"
click node_herutils "https://github.com/jaypatil9/hexapawnrl/blob/main/HER/utils.py"
click node_herstates "https://github.com/jaypatil9/hexapawnrl/blob/main/HER/states.txt"
click node_himagent "https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/agent.py"
click node_himtrainer "https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/train.py"
click node_himutils "https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/utils.py"
click node_himstates "https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/states.txt"
click node_bfagent "https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/agent.py"
click node_bfsearch "https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/train.py"
click node_bfutils "https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/utils.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_rootgame,node_hergame,node_himgame,node_bfgame toneBlue
class node_heragent,node_hertrainer,node_herutils,node_herstates,node_himagent,node_himtrainer,node_himutils,node_himstates toneAmber
class node_bfagent,node_bfsearch,node_bfutils toneMint
class node_human toneIndigo
```

## Components

### Game play

- [Standalone game](https://github.com/jaypatil9/hexapawnrl/blob/main/game.py): `game.py`
- [HER game](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/game.py): `HER/game.py`
- [HIM game](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/game.py): `HIM/game.py`
- [Solver game](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/game.py): `brute_force/game.py`

### Learning agents

- [HER agent](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/agent.py): `HER/agent.py`
- [HER trainer](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/train.py): `HER/train.py`
- [HER rules](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/utils.py): `HER/utils.py`
- [HER seed states](https://github.com/jaypatil9/hexapawnrl/blob/main/HER/states.txt): `HER/states.txt`
- [HIM agent](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/agent.py): `HIM/agent.py`
- [HIM trainer](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/train.py): `HIM/train.py`
- [HIM rules](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/utils.py): `HIM/utils.py`
- [HIM seed states](https://github.com/jaypatil9/hexapawnrl/blob/main/HIM/states.txt): `HIM/states.txt`

### Brute-force solver

- [Solver agent](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/agent.py): `brute_force/agent.py`
- [Game-tree search](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/train.py): `brute_force/train.py`
- [Solver rules](https://github.com/jaypatil9/hexapawnrl/blob/main/brute_force/utils.py): `brute_force/utils.py`

### Other components

- **Human player**

## Connections

- Human player → Standalone game: plays through
- Human player → HER game: plays through
- Human player → HIM game: plays through
- Human player → Solver game: plays through
- HER game → HER agent: requests moves
- HIM game → HIM agent: requests moves
- Solver game → Solver agent: requests moves
- HER game → HER rules: checks rules
- HIM game → HIM rules: checks rules
- Solver game → Solver rules: checks rules
- HER agent → HER rules: encodes states
- HER agent → HER trainer: trains if needed
- HER trainer → HER seed states: loads seed data
- HER trainer → HER rules: uses rules
- HIM agent → HIM rules: encodes states
- HIM agent → HIM trainer: trains if needed
- HIM trainer → HIM seed states: loads seed data
- HIM trainer → HIM rules: uses rules
- Solver agent → Solver rules: selects legal moves
- Game-tree search → Solver rules: enumerates moves
- Solver game → Solver rules: configures agent rules
