# gabrielkaos/chessenginegoobc architecture

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

- Interactive diagram: https://gitdiagram.com/gabrielkaos/chessenginegoobc
- Repository: https://github.com/gabrielkaos/chessenginegoobc

## Overview

GOOB is a UCI-playing C chess engine with NNUE evaluation and a separate NNUE data/training toolchain. The main runtime path accepts UCI commands, searches chess positions, and reports moves and analysis. The graph also preserves move generation, tablebases, tracing, and training capabilities. Most links are based on the SOURCE INDEX’s references; unsampled implementation details are not inferred beyond those references and README statements.

Main entry points: [`src/search.c`](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/search.c) (Search), [`src/uci.c`](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/uci.c) (UCI protocol), [`src/movegen.c`](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/movegen.c) (Move generation), [`tools/nnue_project/scripts/train.py`](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/train.py) (NNUE training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Engine runtime"]
  node_main["Engine entry<br/>[main.c]"]
  node_uci["UCI protocol<br/>[uci.c]"]
  node_init["Engine initialization<br/>[init.c]"]
end

subgraph group_chess["Chess position"]
  node_board["Position state<br/>[board.c]"]
  node_movegen["Move generation<br/>[movegen.c]"]
  node_attacks["Attack tables<br/>[attacks.c]"]
  node_makemove["Move execution<br/>[makemove.c]"]
end

subgraph group_search["Search and evaluation"]
  node_search["Search<br/>[search.c]"]
  node_movepicker["Move ordering<br/>[movepicker.c]"]
  node_evaluate["Position evaluation<br/>[evaluate.c]"]
  node_nnue["NNUE inference<br/>[nnue_loader.h]"]
  node_history["Search histories<br/>[history.c]"]
  node_correction["Evaluation correction<br/>[correction.c]"]
  node_pvtable[("Transposition table<br/>[pvtable.c]")]
end

subgraph group_support["Analysis support"]
  node_syzygy["Tablebase interface<br/>[syzygy.c]"]
  node_tbprobe["Tablebase probing<br/>[tbprobe.c]"]
  node_perft["Perft analysis<br/>[perft.c]"]
  node_trace["Search tracing<br/>[trace.c]"]
end

subgraph group_training["NNUE training"]
  node_fen["FEN utilities<br/>[fen_utils.py]"]
  node_prepare["Training data prep<br/>[prepare_data.py]"]
  node_dataset["NNUE dataset<br/>[nnue_dataset.py]"]
  node_model["NNUE model<br/>[model.py]"]
  node_train["NNUE training<br/>[train.py]"]
  node_export["Weight export<br/>[export_weights.py]"]
end

node_user(("UCI client"))

node_user -->|"starts engine"| node_main
node_main -->|"initializes"| node_init
node_main -->|"dispatches commands"| node_uci
node_uci -->|"starts search"| node_search
node_uci -->|"uses position"| node_board
node_uci -->|"invokes perft"| node_perft
node_uci -->|"configures tables"| node_syzygy
node_search -->|"orders moves"| node_movepicker
node_search -->|"evaluates positions"| node_evaluate
node_search -->|"probes table"| node_pvtable
node_search -->|"generates moves"| node_movegen
node_search -->|"makes moves"| node_makemove
node_search -->|"uses histories"| node_history
node_search -.->|"uses corrections"| node_correction
node_search -.->|"records counters"| node_trace
node_evaluate -.->|"uses inference"| node_nnue
node_movegen -->|"queries attacks"| node_attacks
node_movegen -->|"reads position"| node_board
node_makemove -->|"updates position"| node_board
node_perft -->|"uses generation"| node_movegen
node_perft -->|"makes moves"| node_makemove
node_prepare -->|"parses FEN"| node_fen
node_train -->|"uses model"| node_model
node_train -->|"loads dataset"| node_dataset
node_dataset -->|"uses encoding"| node_fen
node_train -.->|"exports weights"| node_export
node_syzygy -.->|"uses probing"| node_tbprobe

click node_main "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/main.c"
click node_uci "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/uci.c"
click node_init "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/init.c"
click node_board "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/board.c"
click node_movegen "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/movegen.c"
click node_attacks "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/attacks.c"
click node_makemove "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/makemove.c"
click node_search "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/search.c"
click node_movepicker "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/movepicker.c"
click node_evaluate "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/evaluate.c"
click node_nnue "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/nnue_loader.h"
click node_history "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/history.c"
click node_correction "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/correction.c"
click node_pvtable "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/pvtable.c"
click node_syzygy "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/syzygy.c"
click node_tbprobe "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/tbprobe.c"
click node_perft "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/perft.c"
click node_trace "https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/trace.c"
click node_fen "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/fen_utils.py"
click node_prepare "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/prepare_data.py"
click node_dataset "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/nnue_dataset.py"
click node_model "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/model.py"
click node_train "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/train.py"
click node_export "https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/export_weights.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_main,node_uci,node_init,node_user toneBlue
class node_board,node_movegen,node_attacks,node_makemove toneAmber
class node_search,node_movepicker,node_evaluate,node_nnue,node_history,node_correction,node_pvtable toneMint
class node_syzygy,node_tbprobe,node_perft,node_trace toneRose
class node_fen,node_prepare,node_dataset,node_model,node_train,node_export toneIndigo
```

## Components

### Engine runtime

- [Engine entry](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/main.c): `src/main.c`
- [UCI protocol](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/uci.c): `src/uci.c`
- [Engine initialization](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/init.c): `src/init.c`

### Chess position

- [Position state](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/board.c): `src/board.c`
- [Move generation](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/movegen.c): `src/movegen.c`
- [Attack tables](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/attacks.c): `src/attacks.c`
- [Move execution](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/makemove.c): `src/makemove.c`

### Search and evaluation

- [Search](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/search.c): `src/search.c`
- [Move ordering](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/movepicker.c): `src/movepicker.c`
- [Position evaluation](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/evaluate.c): `src/evaluate.c`
- [NNUE inference](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/nnue_loader.h): `src/nnue_loader.h`
- [Search histories](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/history.c): `src/history.c`
- [Evaluation correction](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/correction.c): `src/correction.c`
- [Transposition table](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/pvtable.c): `src/pvtable.c`

### Analysis support

- [Tablebase interface](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/syzygy.c): `src/syzygy.c`
- [Tablebase probing](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/tbprobe.c): `src/tbprobe.c`
- [Perft analysis](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/perft.c): `src/perft.c`
- [Search tracing](https://github.com/gabrielkaos/chessenginegoobc/blob/main/src/trace.c): `src/trace.c`

### NNUE training

- [FEN utilities](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/fen_utils.py): `tools/nnue_project/scripts/fen_utils.py`
- [Training data prep](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/prepare_data.py): `tools/nnue_project/scripts/prepare_data.py`
- [NNUE dataset](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/nnue_dataset.py): `tools/nnue_project/scripts/nnue_dataset.py`
- [NNUE model](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/model.py): `tools/nnue_project/scripts/model.py`
- [NNUE training](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/train.py): `tools/nnue_project/scripts/train.py`
- [Weight export](https://github.com/gabrielkaos/chessenginegoobc/blob/main/tools/nnue_project/scripts/export_weights.py): `tools/nnue_project/scripts/export_weights.py`

### Other components

- **UCI client**

## Connections

- UCI client → Engine entry: starts engine (evidence: `README.md`)
- Engine entry → Engine initialization: initializes (evidence: `src/main.c`)
- Engine entry → UCI protocol: dispatches commands (evidence: `src/main.c`)
- UCI protocol → Search: starts search (evidence: `src/uci.c`)
- UCI protocol → Position state: uses position (evidence: `src/uci.c`)
- UCI protocol → Perft analysis: invokes perft (evidence: `src/uci.c`)
- UCI protocol → Tablebase interface: configures tables (evidence: `src/uci.c`)
- Search → Move ordering: orders moves (evidence: `src/search.c`)
- Search → Position evaluation: evaluates positions (evidence: `src/search.c`)
- Search → Transposition table: probes table (evidence: `src/search.c`)
- Search → Move generation: generates moves (evidence: `src/search.c`)
- Search → Move execution: makes moves (evidence: `src/search.c`)
- Search → Search histories: uses histories (evidence: `src/search.c`)
- Search → Evaluation correction: uses corrections
- Search → Search tracing: records counters
- Position evaluation → NNUE inference: uses inference
- Move generation → Attack tables: queries attacks (evidence: `src/movegen.c`)
- Move generation → Position state: reads position (evidence: `src/movegen.c`)
- Move execution → Position state: updates position
- Perft analysis → Move generation: uses generation (evidence: `src/perft.c`)
- Perft analysis → Move execution: makes moves (evidence: `src/perft.c`)
- Training data prep → FEN utilities: parses FEN (evidence: `tools/nnue_project/scripts/prepare_data.py`)
- NNUE training → NNUE model: uses model (evidence: `tools/nnue_project/scripts/train.py`)
- NNUE training → NNUE dataset: loads dataset (evidence: `tools/nnue_project/scripts/train.py`)
- NNUE dataset → FEN utilities: uses encoding (evidence: `tools/nnue_project/scripts/check_net.py`)
- NNUE training → Weight export: exports weights
- Tablebase interface → Tablebase probing: uses probing
