# gandalf887/oreo architecture

> Architecture diagram of the GitHub repository gandalf887/oreo, 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/gandalf887/oreo
- Repository: https://github.com/gandalf887/oreo

## Overview

Oreo is a bitboard-based chess engine with two documented ways to play: a Raylib graphical interface and a terminal UCI protocol. Both lead to engine move selection, which can consult the opening book or search positions, then return a move to the active interface. The engine’s internal work spans position loading, move generation and legality, evaluation, and iterative search with transposition support. The graph reflects README capabilities and sampled call sites; some implementation details, especially display and search internals, were not fully sampled.

Main entry points: [`Main Files/search.cpp`](https://github.com/gandalf887/oreo/blob/main/Main%20Files/search.cpp) (Iterative search), [`Main Files/main.cpp`](https://github.com/gandalf887/oreo/blob/main/Main%20Files/main.cpp) (Engine startup), [`Main Files/gui.cpp`](https://github.com/gandalf887/oreo/blob/main/Main%20Files/gui.cpp) (Graphical interface), [`Main Files/fen.cpp`](https://github.com/gandalf887/oreo/blob/main/Main%20Files/fen.cpp) (FEN position loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_gui["Graphical interface<br/>[gui.cpp]"]
  node_display["Board display<br/>[display.cpp]"]
  node_uci["UCI protocol<br/>[uci.cpp]"]
  node_entry["Engine startup<br/>[main.cpp]"]
end

subgraph group_rules["Position and rules"]
  node_fen["FEN position loading<br/>[fen.cpp]"]
  node_position["Board representation<br/>[position.h]"]
  node_movegen["Move generation<br/>[movegen.cpp]"]
  node_legal["Move legality<br/>[legal.cpp]"]
  node_make["Make and undo<br/>[makeunmake.cpp]"]
end

subgraph group_engine["Move selection"]
  node_eval["Position evaluation<br/>[eval.cpp]"]
  node_search["Iterative search<br/>[search.cpp]"]
  node_book["Opening book<br/>[book.cpp]"]
end

subgraph group_state["Engine state"]
  node_tt[("Transposition table<br/>[transposition.cpp]")]
  node_zobrist["Position hashing<br/>[zobrist.cpp]"]
end

node_player(("Player or GUI client"))

node_player -->|"plays through"| node_gui
node_player -->|"sends protocol"| node_uci
node_entry -->|"loads start"| node_fen
node_entry -->|"starts"| node_gui
node_entry -.->|"starts"| node_uci
node_fen -->|"creates"| node_position
node_gui -->|"renders board"| node_display
node_gui -->|"requests move"| node_search
node_uci -->|"requests move"| node_search
node_entry -->|"initializes"| node_book
node_search -->|"probes"| node_book
node_search -->|"generates moves"| node_movegen
node_search -->|"checks legality"| node_legal
node_search -->|"applies and reverts"| node_make
node_search -->|"evaluates"| node_eval
node_search -->|"probes and stores"| node_tt
node_make -->|"updates hash"| node_zobrist
node_fen -->|"hashes position"| node_zobrist
node_movegen -->|"checks attacks"| node_legal

click node_gui "https://github.com/gandalf887/oreo/blob/main/Main%20Files/gui.cpp"
click node_display "https://github.com/gandalf887/oreo/blob/main/Main%20Files/display.cpp"
click node_uci "https://github.com/gandalf887/oreo/blob/main/Main%20Files/uci.cpp"
click node_entry "https://github.com/gandalf887/oreo/blob/main/Main%20Files/main.cpp"
click node_fen "https://github.com/gandalf887/oreo/blob/main/Main%20Files/fen.cpp"
click node_position "https://github.com/gandalf887/oreo/blob/main/Main%20Files/position.h"
click node_movegen "https://github.com/gandalf887/oreo/blob/main/Main%20Files/movegen.cpp"
click node_legal "https://github.com/gandalf887/oreo/blob/main/Main%20Files/legal.cpp"
click node_make "https://github.com/gandalf887/oreo/blob/main/Main%20Files/makeunmake.cpp"
click node_eval "https://github.com/gandalf887/oreo/blob/main/Main%20Files/eval.cpp"
click node_search "https://github.com/gandalf887/oreo/blob/main/Main%20Files/search.cpp"
click node_book "https://github.com/gandalf887/oreo/blob/main/Main%20Files/book.cpp"
click node_tt "https://github.com/gandalf887/oreo/blob/main/Main%20Files/transposition.cpp"
click node_zobrist "https://github.com/gandalf887/oreo/blob/main/Main%20Files/zobrist.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_gui,node_display,node_uci,node_entry,node_player toneBlue
class node_fen,node_position,node_movegen,node_legal,node_make toneAmber
class node_eval,node_search,node_book toneMint
class node_tt,node_zobrist toneRose
```

## Components

### User interfaces

- [Graphical interface](https://github.com/gandalf887/oreo/blob/main/Main%20Files/gui.cpp): `Main Files/gui.cpp`
- [Board display](https://github.com/gandalf887/oreo/blob/main/Main%20Files/display.cpp): `Main Files/display.cpp`
- [UCI protocol](https://github.com/gandalf887/oreo/blob/main/Main%20Files/uci.cpp): `Main Files/uci.cpp`
- [Engine startup](https://github.com/gandalf887/oreo/blob/main/Main%20Files/main.cpp): `Main Files/main.cpp`

### Position and rules

- [FEN position loading](https://github.com/gandalf887/oreo/blob/main/Main%20Files/fen.cpp): `Main Files/fen.cpp`
- [Board representation](https://github.com/gandalf887/oreo/blob/main/Main%20Files/position.h): `Main Files/position.h`
- [Move generation](https://github.com/gandalf887/oreo/blob/main/Main%20Files/movegen.cpp): `Main Files/movegen.cpp`
- [Move legality](https://github.com/gandalf887/oreo/blob/main/Main%20Files/legal.cpp): `Main Files/legal.cpp`
- [Make and undo](https://github.com/gandalf887/oreo/blob/main/Main%20Files/makeunmake.cpp): `Main Files/makeunmake.cpp`

### Move selection

- [Position evaluation](https://github.com/gandalf887/oreo/blob/main/Main%20Files/eval.cpp): `Main Files/eval.cpp`
- [Iterative search](https://github.com/gandalf887/oreo/blob/main/Main%20Files/search.cpp): `Main Files/search.cpp`
- [Opening book](https://github.com/gandalf887/oreo/blob/main/Main%20Files/book.cpp): `Main Files/book.cpp`

### Engine state

- [Transposition table](https://github.com/gandalf887/oreo/blob/main/Main%20Files/transposition.cpp): `Main Files/transposition.cpp`
- [Position hashing](https://github.com/gandalf887/oreo/blob/main/Main%20Files/zobrist.cpp): `Main Files/zobrist.cpp`

### Other components

- **Player or GUI client**

## Connections

- Player or GUI client → Graphical interface: plays through
- Player or GUI client → UCI protocol: sends protocol
- Engine startup → FEN position loading: loads start
- Engine startup → Graphical interface: starts
- Engine startup → UCI protocol: starts
- FEN position loading → Board representation: creates
- Graphical interface → Board display: renders board
- Graphical interface → Iterative search: requests move
- UCI protocol → Iterative search: requests move
- Engine startup → Opening book: initializes
- Iterative search → Opening book: probes
- Iterative search → Move generation: generates moves
- Iterative search → Move legality: checks legality
- Iterative search → Make and undo: applies and reverts
- Iterative search → Position evaluation: evaluates
- Iterative search → Transposition table: probes and stores
- Make and undo → Position hashing: updates hash
- FEN position loading → Position hashing: hashes position
- Move generation → Move legality: checks attacks
