104 online 3 members  + Join RP Base  +
FreeScript

RootEngine

by burakdevelopment  ·  version 2026.09.19  ·  updated yesterday

No reviews yet

Downloads
0
Reviews
0
Size
425 KB
Code check
Clean
Licence
MIT
Released
Nov 2026

A free, open-source UCI chess engine in modern C++ magic bitboards, Lazy SMP, Polyglot book support and an experimental NNUE with a full in-repo training pipeli

RootEngine
♜ RootEngine
**A free, open-source UCI chess engine in modern C++ — magic bitboards,
Lazy SMP, Polyglot book support and an experimental NNUE with a full
in-repo training pipeline.**

RootEngine is a from-scratch chess engine focused on clean, dependency-free
C++20 that is easy to read, easy to measure, and easy to improve. It is
OpenBench-compatible and ships with its own match and NNUE training tools,
so anyone can contribute a patch and prove it gains Elo. This README is the
single source of documentation for the whole project: usage, building,
internals, NNUE training and contribution rules are all below.

Contents
  • Features
  • Measured results
  • Usage
  • Building
  • Opening book
  • NNUE: architecture and training
  • Testing tools
  • How the engine works
  • Contributing
  • Roadmap
  • Acknowledgements & license

Features
Board & move generation
  • Bitboard representation with a mailbox for O(1) piece lookup
  • Magic bitboards for sliders, generated at startup (~100 ms)
  • Pseudo-legal generation + post-make legality check; perft-exact on the
standard test suite
  • Polyglot-compatible incremental Zobrist hashing, verified bit-exact
against python-chess on the official test vectors — the same key drives
the transposition table, repetition detection and book probing

Search
  • Iterative deepening principal variation search (PVS) with aspiration windows
  • Lazy SMP multithreading with a shared transposition table
  • Null-move pruning (dynamic R), late move reductions (log-log table),
late move pruning, futility + reverse futility, SEE pruning, internal
iterative reduction, check extensions, mate-distance pruning
  • Killer, countermove and history heuristics (gravity + malus updates)
  • Quiescence search with stand-pat, SEE filtering, delta pruning and TT probing
  • Full UCI time management with best-move-stability scaling

Evaluation
  • Hand-crafted tapered evaluation (PeSTO piece-square tables + mobility,
doubled/isolated/passed pawns, rook on open files, king shield, bishop
pair, tempo)
  • Experimental NNUE (768→256)×2→1, int16 quantized, trained entirely with
the tools in this repository

Extras
  • Native Polyglot .bin opening book probing (tested with Cerebellum 3 Merge)
  • bench, perft, divide, datagen built into the engine
  • No external dependencies — standard library only
Measured results
Test machine: Windows 11, 12 logical cores, GCC 16.1,
-O3 -march=x86-64-v2 -flto. Raw CSVs and charts live in
docs/bench.

Metric, Result

v3.0 vs v2.0 (40 games, 200 ms/move), +158 Elo (+22 =13 -5, 71.2%) [95% CI +72..+267]
First NNUE net vs HCE (30 games, 150 ms), parity: +12 Elo (+9 =13 -8) after ~10 min of training
Speed (1 thread, middlegame), ~2.2 MNPS; depth 20 in ~1 s, depth 27 in ~19 s
SMP scaling, 4.3 MNPS @ 2t, 8.5 @ 4t, 15.9 @ 12t (7.2×)
Perft, exact on 6 standard positions; startpos perft(6) = 119,060,324 in ~3.4 s
Hash compatibility, 8/8 official Polyglot vectors bit-exact vs python-chess
Legality soak, 18 verified self-play games, 0 illegal moves, 0 crashes
Bench signature, 1040462 nodes (deterministic, depth 12)

Perft reference results (all exact, CI-enforced):

Position, Depth, Nodes

startpos, 6, 119,060,324
Kiwipete, 4, 4,085,603
CPW position 3, 5, 674,624
CPW position 5, 4, 2,103,487
CPW position 6, 4, 3,894,594
Usage
RootEngine speaks standard UCI.
Point any chess GUI (Arena, CuteChess, BanksiaGUI, Nibbler, …) at the
binary, or drive it from a terminal:

./Root
uci
setoption name Hash value 256
setoption name Threads value 4
position startpos
go movetime 3000

UCI options
Option, Default, Range, Description

Hash, 64, 1–4096, Transposition table size in MB
Threads, 1, 1–64, Search threads (Lazy SMP)
OwnBook, true, Probe the Polyglot opening book before searching
BookFile, book.bin, Path to a Polyglot .bin book
UseNNUE, false, Neural network evaluation (experimental)
EvalFile, root.nnue, Path to an RTNN .nnue network

Relative BookFile/EvalFile paths are resolved against the working
directory first, then the executable's directory.
Console commands (besides standard UCI)
Command, Description

bench [depth], Deterministic benchmark over 12 fixed positions; prints Bench: nodes nps. Also available as ./Root bench from the command line (OpenBench-compatible)
perft N, Node count to depth N from the current position
divide N, Per-root-move perft breakdown
d, Print the board and the Polyglot hash
eval, Static evaluation of the current position
datagen , Generate NNUE training data via self-play
Building
Requires a C++20 compiler (GCC 11+ or Clang 14+). No dependencies.

make            # portable binary (x86-64-v2: any CPU from ~2009+)
make native     # fastest binary for your CPU
make debug      # -O0 -g

With CMake instead: cmake -B build-cmake && cmake --build build-cmake.

On Windows, install GCC via WinLibs or MSYS2 UCRT64;
the Makefile links statically so the binary runs standalone. CI builds and
tests Linux + Windows on every push.
Opening book
RootEngine reads standard Polyglot .bin books. No book is bundled (they
are large binaries); any Polyglot book works — for example
Cerebellum. Drop it next to the
engine as book.bin, or point BookFile at it.

Implementation notes: because the engine's Zobrist key is the Polyglot
key, probing is a direct binary search on the file with zero extra hashing.
Castling moves are translated from Polyglot's king-takes-rook encoding, and
every book move is validated against the legal move list before being
played — a book can never make the engine play an illegal move. Among the
book entries the highest-weight move is chosen (random tie-break).
NNUE: architecture and trainingArchitecture
`
(768 → 256)×2 → 1 perspective netw

…