# maxolek/tomahawk architecture

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

- Interactive diagram: https://gitdiagram.com/maxolek/tomahawk
- Repository: https://github.com/maxolek/tomahawk

## Overview

Tomahawk is a standalone UCI chess engine. A GUI or other UCI client sends position, option, and search commands; the engine prepares the game position, searches legal continuations, evaluates positions, and returns a best move and search information. Its documented search techniques and NNUE evaluation are represented alongside the board, move-generation, and evaluation layers. The sampled excerpts show the engine’s search/evaluation dependencies, but not complete UCI dispatch or asset-loading implementations, so those internal links are omitted where uncertain.

Main entry points: [`src/engine.cpp`](https://github.com/maxolek/tomahawk/blob/main/src/engine.cpp) (Engine), [`src/searcher.cpp`](https://github.com/maxolek/tomahawk/blob/main/src/searcher.cpp) (Iterative search), [`src/moveGenerator.cpp`](https://github.com/maxolek/tomahawk/blob/main/src/moveGenerator.cpp) (Move generation), [`src/UCI.cpp`](https://github.com/maxolek/tomahawk/blob/main/src/UCI.cpp) (UCI protocol)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["UCI interface"]
  node_uci["UCI protocol<br/>[UCI.cpp]"]
end

subgraph group_engine["Game orchestration"]
  node_engine_core["Engine<br/>[engine.cpp]"]
  node_game_state["Game state<br/>[gamestate.cpp]"]
end

subgraph group_position["Position and moves"]
  node_board["Board state<br/>[board.cpp]"]
  node_movegen["Move generation<br/>[moveGenerator.cpp]"]
  node_move_data["Precomputed move data"]
  node_magics["Sliding attacks<br/>[magics.cpp]"]
end

subgraph group_search["Search and evaluation"]
  node_searcher["Iterative search<br/>[searcher.cpp]"]
  node_eval["Classical evaluation<br/>[evaluator.cpp]"]
  node_nnue["NNUE inference<br/>[NNUE.cpp]"]
  node_tt["Transposition table<br/>[tt.h]"]
  node_book["Opening book<br/>[book.cpp]"]
end

subgraph group_resources["Runtime resources"]
  node_weights["NNUE weights"]
  node_opening_books["Book files"]
  node_pst["Piece-square tables"]
end

node_client(("UCI client"))

node_client -->|"sends commands"| node_uci
node_uci -->|"dispatches commands"| node_engine_core
node_engine_core -->|"sets position"| node_board
node_engine_core -->|"tracks game"| node_game_state
node_engine_core -->|"generates legal moves"| node_movegen
node_engine_core -->|"starts search"| node_searcher
node_engine_core -->|"uses opening book"| node_book
node_searcher -->|"searches position"| node_board
node_searcher -->|"generates moves"| node_movegen
node_searcher -->|"evaluates position"| node_eval
node_searcher -->|"updates accumulator"| node_nnue
node_searcher -->|"probes and stores"| node_tt
node_board -->|"queries attacks"| node_magics
node_movegen -->|"uses lookup data"| node_move_data
node_movegen -->|"queries attacks"| node_magics
node_uci -->|"returns best move"| node_client
node_weights -.->|"network parameters"| node_nnue
node_opening_books -.->|"book data"| node_book
node_pst -.->|"table data"| node_eval

click node_uci "https://github.com/maxolek/tomahawk/blob/main/src/UCI.cpp"
click node_engine_core "https://github.com/maxolek/tomahawk/blob/main/src/engine.cpp"
click node_game_state "https://github.com/maxolek/tomahawk/blob/main/src/gamestate.cpp"
click node_board "https://github.com/maxolek/tomahawk/blob/main/src/board.cpp"
click node_movegen "https://github.com/maxolek/tomahawk/blob/main/src/moveGenerator.cpp"
click node_move_data "https://github.com/maxolek/tomahawk/blob/main/src/PrecomputedMoveData.cpp"
click node_magics "https://github.com/maxolek/tomahawk/blob/main/src/magics.cpp"
click node_searcher "https://github.com/maxolek/tomahawk/blob/main/src/searcher.cpp"
click node_eval "https://github.com/maxolek/tomahawk/blob/main/src/evaluator.cpp"
click node_nnue "https://github.com/maxolek/tomahawk/blob/main/src/NNUE.cpp"
click node_tt "https://github.com/maxolek/tomahawk/blob/main/include/tt.h"
click node_book "https://github.com/maxolek/tomahawk/blob/main/src/book.cpp"
click node_weights "https://github.com/maxolek/tomahawk/tree/main/bin/nnue_wgts"
click node_opening_books "https://github.com/maxolek/tomahawk/tree/main/bin/opening_books"
click node_pst "https://github.com/maxolek/tomahawk/tree/main/bin/pst"

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_uci,node_client toneBlue
class node_engine_core,node_game_state toneAmber
class node_board,node_movegen,node_move_data,node_magics toneMint
class node_searcher,node_eval,node_nnue,node_tt,node_book toneRose
class node_weights,node_opening_books,node_pst toneIndigo
```

## Components

### UCI interface

- [UCI protocol](https://github.com/maxolek/tomahawk/blob/main/src/UCI.cpp): `src/UCI.cpp`

### Game orchestration

- [Engine](https://github.com/maxolek/tomahawk/blob/main/src/engine.cpp): `src/engine.cpp`
- [Game state](https://github.com/maxolek/tomahawk/blob/main/src/gamestate.cpp): `src/gamestate.cpp`

### Position and moves

- [Board state](https://github.com/maxolek/tomahawk/blob/main/src/board.cpp): `src/board.cpp`
- [Move generation](https://github.com/maxolek/tomahawk/blob/main/src/moveGenerator.cpp): `src/moveGenerator.cpp`
- [Precomputed move data](https://github.com/maxolek/tomahawk/blob/main/src/PrecomputedMoveData.cpp): `src/PrecomputedMoveData.cpp`
- [Sliding attacks](https://github.com/maxolek/tomahawk/blob/main/src/magics.cpp): `src/magics.cpp`

### Search and evaluation

- [Iterative search](https://github.com/maxolek/tomahawk/blob/main/src/searcher.cpp): `src/searcher.cpp`
- [Classical evaluation](https://github.com/maxolek/tomahawk/blob/main/src/evaluator.cpp): `src/evaluator.cpp`
- [NNUE inference](https://github.com/maxolek/tomahawk/blob/main/src/NNUE.cpp): `src/NNUE.cpp`
- [Transposition table](https://github.com/maxolek/tomahawk/blob/main/include/tt.h): `include/tt.h`
- [Opening book](https://github.com/maxolek/tomahawk/blob/main/src/book.cpp): `src/book.cpp`

### Runtime resources

- [NNUE weights](https://github.com/maxolek/tomahawk/tree/main/bin/nnue_wgts): `bin/nnue_wgts`
- [Book files](https://github.com/maxolek/tomahawk/tree/main/bin/opening_books): `bin/opening_books`
- [Piece-square tables](https://github.com/maxolek/tomahawk/tree/main/bin/pst): `bin/pst`

### Other components

- **UCI client**

## Connections

- UCI client → UCI protocol: sends commands
- UCI protocol → Engine: dispatches commands
- Engine → Board state: sets position
- Engine → Game state: tracks game
- Engine → Move generation: generates legal moves
- Engine → Iterative search: starts search
- Engine → Opening book: uses opening book
- Iterative search → Board state: searches position
- Iterative search → Move generation: generates moves
- Iterative search → Classical evaluation: evaluates position
- Iterative search → NNUE inference: updates accumulator
- Iterative search → Transposition table: probes and stores
- Board state → Sliding attacks: queries attacks
- Move generation → Precomputed move data: uses lookup data
- Move generation → Sliding attacks: queries attacks
- UCI protocol → UCI client: returns best move
- NNUE weights → NNUE inference: network parameters
- Book files → Opening book: book data
- Piece-square tables → Classical evaluation: table data
