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
**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
Board & move generation
the transposition table, repetition detection and book probing
Search
iterative reduction, check extensions, mate-distance pruning
pair, tempo)
Extras
Test machine: Windows 11, 12 logical cores, GCC 16.1,
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,
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:
UCI options
Option, Default, Range, Description
Relative
directory first, then the executable's directory.
Console commands (besides standard UCI)
Command, Description
Building
Requires a C++20 compiler (GCC 11+ or Clang 14+). No dependencies.
With CMake instead:
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
are large binaries); any Polyglot book works — for example
Cerebellum. Drop it next to the
engine as
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
…
**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
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
- Polyglot-compatible incremental Zobrist hashing, verified bit-exact
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),
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
- Hand-crafted tapered evaluation (PeSTO piece-square tables + mobility,
pair, tempo)
- Experimental NNUE
(768→256)×2→1, int16 quantized, trained entirely with
Extras
- Native Polyglot
.binopening book probing (tested with Cerebellum 3 Merge) bench,perft,divide,datagenbuilt into the engine- No external dependencies — standard library only
Test machine: Windows 11, 12 logical cores, GCC 16.1,
-O3 -march=x86-64-v2 -flto. Raw CSVs and charts live indocs/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 3000UCI options
Option, Default, Range, Description
Hash, 64, 1–4096, Transposition table size in MBThreads, 1, 1–64, Search threads (Lazy SMP)OwnBook, true, Probe the Polyglot opening book before searchingBookFile, book.bin, Path to a Polyglot .bin bookUseNNUE, false, Neural network evaluation (experimental)EvalFile, root.nnue, Path to an RTNN .nnue networkRelative
BookFile/EvalFile paths are resolved against the workingdirectory 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 positiondivide N, Per-root-move perft breakdownd, Print the board and the Polyglot hasheval, Static evaluation of the current positiondatagen , Generate NNUE training data via self-playBuilding
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 -gWith 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 (theyare 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
…