# kachhy/onslaught architecture

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

- Interactive diagram: https://gitdiagram.com/kachhy/onslaught
- Repository: https://github.com/kachhy/onslaught

## Overview

Onslaught is a UCI-compliant C++ chess engine. A UCI GUI supplies commands and positions; the engine maintains a chess board, searches legal continuations, evaluates positions, and reports moves and analysis. Separate modes support self-play data generation and parameter tuning. The graph preserves move generation, NNUE evaluation, transposition caching, and Syzygy tablebase support. Some subsystem links are dashed because the available excerpts show declarations or imports, not the runtime calls; the documented UCI workflow is cited to the README.

Main entry points: [`src/search-eval/search.cpp`](https://github.com/kachhy/onslaught/blob/main/src/search-eval/search.cpp) (Search), [`src/main.cpp`](https://github.com/kachhy/onslaught/blob/main/src/main.cpp) (Program Entry), [`src/uci/uci.cpp`](https://github.com/kachhy/onslaught/blob/main/src/uci/uci.cpp) (UCI Protocol), [`src/board/board.cpp`](https://github.com/kachhy/onslaught/blob/main/src/board/board.cpp) (Board State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Engine Interface"]
  node_entry["Program Entry<br/>[main.cpp]"]
  node_uci["UCI Protocol<br/>[uci.cpp]"]
end

subgraph group_position["Chess Position"]
  node_board["Board State<br/>[board.cpp]"]
  node_rules["Chess Rules<br/>[rules.cpp]"]
  node_movegen["Move Generation<br/>[movegen.cpp]"]
  node_attacks["Attack Tables<br/>[attacks.cpp]"]
  node_core["Move and Bitboards"]
end

subgraph group_search["Search and Evaluation"]
  node_searcher["Search<br/>[search.cpp]"]
  node_eval["Position Evaluation<br/>[eval.cpp]"]
  node_ordering["Move Ordering<br/>[movepicker.cpp]"]
  node_history["Search Heuristics<br/>[history.cpp]"]
  node_tt[("Transposition Table<br/>[transposition.cpp]")]
  node_nnue["NNUE Network<br/>[nnue.cpp]"]
  node_syzygy["Syzygy Tablebases<br/>[tbprobe.c]"]
end

subgraph group_support["Engine Support"]
  node_zobrist["Position Hashing<br/>[zobrist.cpp]"]
end

subgraph group_data["Data and Tuning"]
  node_datagen["Data Generation<br/>[datagen.cpp]"]
  node_packing["Packed Positions<br/>[viriformat.h]"]
  node_tuning["Parameter Tuning<br/>[tuning.cpp]"]
end

node_gui(("UCI GUI"))

node_gui -->|"sends commands"| node_uci
node_uci -->|"reports analysis"| node_gui
node_entry -->|"starts protocol"| node_uci
node_entry -->|"starts mode"| node_datagen
node_entry -->|"loads network"| node_nnue
node_entry -->|"initializes tables"| node_attacks
node_entry -->|"initializes keys"| node_zobrist
node_entry -->|"initializes reductions"| node_tuning
node_uci -.->|"dispatches search"| node_searcher
node_uci -.->|"updates position"| node_board
node_searcher -.->|"searches position"| node_board
node_searcher -->|"probes and stores"| node_tt
node_searcher -.->|"evaluates positions"| node_eval
node_searcher -.->|"generates candidates"| node_movegen
node_searcher -.->|"orders candidates"| node_ordering
node_searcher -.->|"updates heuristics"| node_history
node_searcher -.->|"probes endings"| node_syzygy
node_board -.->|"hashes positions"| node_zobrist
node_board -.->|"maintains accumulator"| node_nnue
node_board -.->|"packs position"| node_packing
node_movegen -.->|"uses attack tables"| node_attacks
node_movegen -.->|"emits moves"| node_core
node_datagen -.->|"generates games"| node_searcher
node_datagen -.->|"encodes samples"| node_packing

click node_entry "https://github.com/kachhy/onslaught/blob/main/src/main.cpp"
click node_uci "https://github.com/kachhy/onslaught/blob/main/src/uci/uci.cpp"
click node_board "https://github.com/kachhy/onslaught/blob/main/src/board/board.cpp"
click node_rules "https://github.com/kachhy/onslaught/blob/main/src/board/rules.cpp"
click node_movegen "https://github.com/kachhy/onslaught/blob/main/src/movegen/movegen.cpp"
click node_attacks "https://github.com/kachhy/onslaught/blob/main/src/movegen/attacks.cpp"
click node_core "https://github.com/kachhy/onslaught/tree/main/src/core"
click node_searcher "https://github.com/kachhy/onslaught/blob/main/src/search-eval/search.cpp"
click node_eval "https://github.com/kachhy/onslaught/blob/main/src/search-eval/eval.cpp"
click node_ordering "https://github.com/kachhy/onslaught/blob/main/src/search-eval/movepicker.cpp"
click node_history "https://github.com/kachhy/onslaught/blob/main/src/search-eval/history.cpp"
click node_tt "https://github.com/kachhy/onslaught/blob/main/src/hash/transposition.cpp"
click node_nnue "https://github.com/kachhy/onslaught/blob/main/src/nnue/nnue.cpp"
click node_syzygy "https://github.com/kachhy/onslaught/blob/main/src/syzygy/tbprobe.c"
click node_zobrist "https://github.com/kachhy/onslaught/blob/main/src/hash/zobrist.cpp"
click node_datagen "https://github.com/kachhy/onslaught/blob/main/src/datagen/datagen.cpp"
click node_packing "https://github.com/kachhy/onslaught/blob/main/src/binpack/viriformat.h"
click node_tuning "https://github.com/kachhy/onslaught/blob/main/src/search-eval/tuning.cpp"

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_entry,node_uci,node_gui toneBlue
class node_board,node_rules,node_movegen,node_attacks,node_core toneAmber
class node_searcher,node_eval,node_ordering,node_history,node_tt,node_nnue,node_syzygy toneMint
class node_zobrist toneRose
class node_datagen,node_packing,node_tuning toneIndigo
```

## Components

### Engine Interface

- [Program Entry](https://github.com/kachhy/onslaught/blob/main/src/main.cpp): `src/main.cpp`
- [UCI Protocol](https://github.com/kachhy/onslaught/blob/main/src/uci/uci.cpp): `src/uci/uci.cpp`

### Chess Position

- [Board State](https://github.com/kachhy/onslaught/blob/main/src/board/board.cpp): `src/board/board.cpp`
- [Chess Rules](https://github.com/kachhy/onslaught/blob/main/src/board/rules.cpp): `src/board/rules.cpp`
- [Move Generation](https://github.com/kachhy/onslaught/blob/main/src/movegen/movegen.cpp): `src/movegen/movegen.cpp`
- [Attack Tables](https://github.com/kachhy/onslaught/blob/main/src/movegen/attacks.cpp): `src/movegen/attacks.cpp`
- [Move and Bitboards](https://github.com/kachhy/onslaught/tree/main/src/core): `src/core`

### Search and Evaluation

- [Search](https://github.com/kachhy/onslaught/blob/main/src/search-eval/search.cpp): `src/search-eval/search.cpp`
- [Position Evaluation](https://github.com/kachhy/onslaught/blob/main/src/search-eval/eval.cpp): `src/search-eval/eval.cpp`
- [Move Ordering](https://github.com/kachhy/onslaught/blob/main/src/search-eval/movepicker.cpp): `src/search-eval/movepicker.cpp`
- [Search Heuristics](https://github.com/kachhy/onslaught/blob/main/src/search-eval/history.cpp): `src/search-eval/history.cpp`
- [Transposition Table](https://github.com/kachhy/onslaught/blob/main/src/hash/transposition.cpp): `src/hash/transposition.cpp`
- [NNUE Network](https://github.com/kachhy/onslaught/blob/main/src/nnue/nnue.cpp): `src/nnue/nnue.cpp`
- [Syzygy Tablebases](https://github.com/kachhy/onslaught/blob/main/src/syzygy/tbprobe.c): `src/syzygy/tbprobe.c`

### Engine Support

- [Position Hashing](https://github.com/kachhy/onslaught/blob/main/src/hash/zobrist.cpp): `src/hash/zobrist.cpp`

### Data and Tuning

- [Data Generation](https://github.com/kachhy/onslaught/blob/main/src/datagen/datagen.cpp): `src/datagen/datagen.cpp`
- [Packed Positions](https://github.com/kachhy/onslaught/blob/main/src/binpack/viriformat.h): `src/binpack/viriformat.h`
- [Parameter Tuning](https://github.com/kachhy/onslaught/blob/main/src/search-eval/tuning.cpp): `src/search-eval/tuning.cpp`

### Other components

- **UCI GUI**

## Connections

- UCI GUI → UCI Protocol: sends commands
- UCI Protocol → UCI GUI: reports analysis
- Program Entry → UCI Protocol: starts protocol (evidence: `src/main.cpp`)
- Program Entry → Data Generation: starts mode (evidence: `src/main.cpp`)
- Program Entry → NNUE Network: loads network (evidence: `src/main.cpp`)
- Program Entry → Attack Tables: initializes tables (evidence: `src/main.cpp`)
- Program Entry → Position Hashing: initializes keys (evidence: `src/main.cpp`)
- Program Entry → Parameter Tuning: initializes reductions (evidence: `src/main.cpp`)
- UCI Protocol → Search: dispatches search
- UCI Protocol → Board State: updates position
- Search → Board State: searches position
- Search → Transposition Table: probes and stores (evidence: `src/search-eval/search.cpp`)
- Search → Position Evaluation: evaluates positions
- Search → Move Generation: generates candidates
- Search → Move Ordering: orders candidates
- Search → Search Heuristics: updates heuristics
- Search → Syzygy Tablebases: probes endings
- Board State → Position Hashing: hashes positions
- Board State → NNUE Network: maintains accumulator
- Board State → Packed Positions: packs position
- Move Generation → Attack Tables: uses attack tables
- Move Generation → Move and Bitboards: emits moves (evidence: `src/movegen/movegen.cpp`)
- Data Generation → Search: generates games
- Data Generation → Packed Positions: encodes samples (evidence: `src/datagen/datagen.cpp`)
