# kieranram/minesweeper_rl architecture

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

- Interactive diagram: https://gitdiagram.com/kieranram/minesweeper_rl
- Repository: https://github.com/kieranram/minesweeper_rl

## Overview

This repository is a Minesweeper reinforcement-learning agent: it repeatedly plays a generated board, learns action values from logged outcomes, and periodically evaluates and saves the model. Its runtime has two substantial components, so the graph focuses on their actual responsibilities rather than introducing unsampled stages. The README documents convolutional value estimation, epsilon-guided training, replay sampling, testing, board-size transfer, and game visualization; the code excerpts show the agent/environment calls and model operations. Model artifacts are present in the tree, but their loading and use are not linked here without further evidence.

Main entry points: [`network.py`](https://github.com/kieranram/minesweeper_rl/blob/main/network.py) (DQ sweeper), [`minefield.py`](https://github.com/kieranram/minesweeper_rl/blob/main/minefield.py) (Board and rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Learning agent"]
  node_learner["DQ sweeper<br/>[network.py]"]
  node_training_log[("Training log<br/>[network.py]")]
  node_q_network["Convolutional Q-network<br/>[network.py]"]
  node_evaluation["Test evaluation<br/>[network.py]"]
  node_visualization["Game visualization<br/>[network.py]"]
end

subgraph group_game["Minesweeper environment"]
  node_minefield["Board and rules<br/>[minefield.py]"]
  node_board_state[("Board state<br/>[minefield.py]")]
end

node_player(("Training run"))

node_player -.->|"starts training"| node_learner
node_learner -->|"primes and steps"| node_minefield
node_minefield -->|"returns observations"| node_learner
node_minefield -->|"updates"| node_board_state
node_learner -->|"logs outcomes"| node_training_log
node_learner -->|"predicts and trains"| node_q_network
node_learner -->|"runs periodic tests"| node_evaluation
node_evaluation -->|"runs episodes"| node_learner
node_learner -->|"renders game"| node_visualization

click node_learner "https://github.com/kieranram/minesweeper_rl/blob/main/network.py"
click node_training_log "https://github.com/kieranram/minesweeper_rl/blob/main/network.py"
click node_q_network "https://github.com/kieranram/minesweeper_rl/blob/main/network.py"
click node_evaluation "https://github.com/kieranram/minesweeper_rl/blob/main/network.py"
click node_visualization "https://github.com/kieranram/minesweeper_rl/blob/main/network.py"
click node_minefield "https://github.com/kieranram/minesweeper_rl/blob/main/minefield.py"
click node_board_state "https://github.com/kieranram/minesweeper_rl/blob/main/minefield.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_learner,node_training_log,node_q_network,node_evaluation,node_visualization toneBlue
class node_minefield,node_board_state toneAmber
class node_player toneIndigo
```

## Components

### Learning agent

- [DQ sweeper](https://github.com/kieranram/minesweeper_rl/blob/main/network.py): `network.py`
- [Training log](https://github.com/kieranram/minesweeper_rl/blob/main/network.py): `network.py`
- [Convolutional Q-network](https://github.com/kieranram/minesweeper_rl/blob/main/network.py): `network.py`
- [Test evaluation](https://github.com/kieranram/minesweeper_rl/blob/main/network.py): `network.py`
- [Game visualization](https://github.com/kieranram/minesweeper_rl/blob/main/network.py): `network.py`

### Minesweeper environment

- [Board and rules](https://github.com/kieranram/minesweeper_rl/blob/main/minefield.py): `minefield.py`
- [Board state](https://github.com/kieranram/minesweeper_rl/blob/main/minefield.py): `minefield.py`

### Other components

- **Training run**

## Connections

- Training run → DQ sweeper: starts training
- DQ sweeper → Board and rules: primes and steps (evidence: `network.py`)
- Board and rules → DQ sweeper: returns observations (evidence: `network.py`)
- Board and rules → Board state: updates (evidence: `minefield.py`)
- DQ sweeper → Training log: logs outcomes (evidence: `network.py`)
- DQ sweeper → Convolutional Q-network: predicts and trains (evidence: `network.py`)
- DQ sweeper → Test evaluation: runs periodic tests (evidence: `network.py`)
- Test evaluation → DQ sweeper: runs episodes (evidence: `network.py`)
- DQ sweeper → Game visualization: renders game (evidence: `network.py`)
