Build a Chess Engine — hardcover edition, 3D view of the front cover and spine
Build · Verify · Measure

Build a Chess Engine

From Legal Moves to Neural Networks

Build a real chess engine and prove it works. Go from legal moves to timed UCI search, measure every improvement, and understand how modern engines extend the same foundation with advanced search and neural evaluation.

One complete book. Three formats.

Every edition contains the same complete book — the engine course, the Beyond the Engine software-project part, and the appendices. The difference is format only. Scan a code or follow the link to the Amazon listing.

E-bookKindle

The same book in full color on screen. Reflowable Kindle edition with live cross-references and links.

Kindle e-book · full color ASIN B0HD9RCHQW
PrintPaperback

The complete book at the lowest print cost. Black-and-white interior on crisp white paper, 8.5″ × 11″.

Paperback · 442 pages · black & white ISBN 9798191043098
PrintHardcover

The full semantic color system in a durable case-laminate format. Premium color interior, 8.25″ × 11″.

Hardcover · 442 pages · premium color ISBN 9798190877175

Links open the Amazon.com listing; each edition is also available on Amazon’s international marketplaces.

Not sure yet? Try before you buy — play with the book’s algorithms live in your browser or read a free sample. No signup, nothing to install.

An engine you can trust, end to end.

By the classical stopping point, your engine can…

  • replay legal positions and play complete games
  • find mate and return deterministic fixed-work results
  • survive full-state and perft checks
  • stop before a hard deadline, every time
  • speak UCI through one responsive worker
  • run controlled, paired engine matches
  • package a known-good release

From first principles to modern architecture.

Board representation · Move generation · Perft
Alpha-beta · Transposition tables · Evaluation
UCI · Testing · NNUE · Policy-value MCTS
Databases · Notation · Analysis · Puzzles · Visualization

Correctness before speed

Every subsystem gets a simple required path and a specific oracle. You do not optimize an engine whose state you cannot restore.

Diagnosis, not answer dumping

Predict exercises, focused fixtures, and Bug Laboratories teach you to turn one bad total or protocol symptom into one violated invariant.

Measurement without mythology

Fixed-work benchmarks, paired openings, confidence intervals, and SPRT distinguish a faster program from a stronger engine — and a real improvement from noise.

Modern architecture with honest boundaries

NNUE, policy-value MCTS, self-play, and hybrid designs connect to the classical engine through explicit data and inference contracts.

Experience converted into decisions

Janus case studies show what was tested, what happened, and what to generalize. Failed and inconclusive results stay failed and inconclusive.

The algorithms, running in your browser.

A free interactive companion: play the engine, watch alpha-beta prune a real search tree, step through bitboard move generation, verify perft counts against the book’s tables, and run an SPRT test yourself. A taste of every part of the book — the derivations live in the book.

Open the interactive companion →
Interactive companion preview: bitboard move generation stepping through shifts and masks

Programmers who finish projects.

You should know the rules of chess and be comfortable with functions, arrays or structs, loops, recursion, and tests. You do not need to be a strong chess player or know bitboards in advance.

Examples are language-neutral, with implementation notes for Rust, C++, Python, and other common choices.

The classical engine is built end to end; the neural chapters are advanced implementation roadmaps. No trained network or turnkey training release is included — and none is implied.

Lennart A. Conrad

Lennart A. Conrad is the developer of Janus, a Rust chess engine. Chess programming was how he learned to program in practice: an early playing application grew into chess-data and puzzle tools, a Java engine, and eventually Janus.

His work on Janus connects rule correctness, search, evaluation, profiling, protocol design, controlled engine matches, and neural inference. Just as important, it records ideas that failed, measured no effect, or needed better evidence. That experience shapes Build a Chess Engine: begin with one simple correct path, make every state transition reversible, use tests that localize mistakes, and earn complexity through measurement.

QR code linking to Lennart A. Conrad’s GitHub profile
Code on GitHub →

More of the author’s chess software is open source — including the deterministic toolkit that generated this book’s diagrams.