Consider challenging me on Lichess!
A UCI-compatible chess engine written in C++.
- Parses FEN and setups board internally
- Legal Move Generation in a given position and core engine system
- Achieved Search speed of
2.65M nodes/sec, validated via Basic & Perft testing - Core Engine Logic: Implemented Zobrist Hashing, a Transposition Table for PV retrieval, and a move-ordering system Heuristics.
- UCI compatible and deployed it as a
Lichess bot - Integrated Polyglot Support: Implemented PolyKey generation and integrated
komodo.binfor high-performance opening theory.
- Protocol: UCI (Universal Chess Interface)
- Language: C++ Build System: Make
- Start date: July 8, 2025
- Run targets:
- UCI GUIs
- Lichess via python lichess API
- Iterative deepening (
SearchPosition) - Alpha-beta search (
AlphaBeta) - Quiescence search on captures (
Quiescence) - Basic repetition / 50-move detection
- Null move pruning (R=3)
- Late move reduction (LMR)
- MVV-LVA capture scoring
- Killer moves
- History heuristic
- Format: Polyglot/Komodo binary books (e.g.
komodo.bin). - Usage: Place a book at
openingBook/komodo.binor set thePOLYBOOKenvironment variable to a custom path. - Behavior: When present the engine will load the book at startup and prefer book moves (weighted-random selection) before running the search.
- Material + piece-square tables (PST)
- Bishop pair bonus
- King safety / castling related terms
- Hanging piece penalties (with stronger opening penalties for hanging minors)
- Endgame-only passed pawn bonus
- Zobrist keys
- PV / hash move probing and storage
- Parses
go wtime/btime/winc/binc/movestogo/movetime/depth/infinite - Sets a
stoptimeand stops search when time is exceeded - Auto-reduces depth in very low time situations when depth is not specified
src/ contains the engine implementation:
uci.cpp: UCI loop + command parsingsearch.cpp: alpha-beta, quiescence, iterative deepening, time stop checksevaluate.cpp: evaluation function and termsmovegen.cpp: move generationmakemove.cpp: make/take movesmoveorder.cpp: move scoring / orderingpvtable.cpp: transposition table and PV line handlinginit.cpp: initialization tablesmisc.cpp: to retrieve the current time in millisecondsattack.cpp: attack detectionboard.cpp: board parsing / FENdefs.h,struct.h: core constants and structures
Requirements:
g++(MinGW-w64)make(optional)
From the project root:
g++ -O2 -std=c++17 -Isrc src/*.cpp -o sarun.exe./sarunExample UCI session:
uci
isready
ucinewgame
position startpos
go wtime 60000 btime 60000 winc 0 binc 0 movestogo 30
uciisreadyucinewgameposition startpos [moves ...]position fen <fen> [moves ...]go depth Ngo movetime MSgo wtime MS btime MS winc MS binc MS movestogo Ngo infinitestopquit
This project was built to deeply understand:
- Low-level performance-oriented C++ systems
- Game Theory, Game tree search and optimization techniques
- Caching, hashing, and time-constrained decision making
- Debugging complex states and iterative development
Rather than using existing engines, everything was implemented from scratch to gain hands-on experience with real-world algorithmic trade-offs.
- Stockfish for inspiration
- Chess Programming Wiki — implementation references and techniques
- BlueFever Software (VICE) for the educational foundation and core Algorithms
- Chess Stack Exchange - For community expertise and technical problem-solving.
#Opening Theory
- Polyglot format — For polyKey Generation and opening book interoperability based on the standard Polyglot specifications.
- Komodo Chess — This engine uses the komodo.bin Polyglot book provided by Komodo Chess to handle opening theory.