A chess engine written in C, using bitboards and tested with Criterion.
It can load FEN positions, generate all legal moves, and run perft tests to validate move generation.
├── assets/ # Resources (images, ...)
├── lib/
│ └── chessboard/ # Engine headers
├── src/
│ └── chessboard/ # Engine source code
├── tests/ # Unit tests (Criterion)
├── Makefile # Build system
└── README.md # This file
- gcc or clang
- make
- Criterion for tests
sudo apt-get install libcriterion-dev
make ui
make run
make test
-
Load positions via FEN ✅
-
Generate all legal moves ✅
-
Play a game through a GUI ✅
-
Validate move generation using perft tests ✅
-
Position evaluation (WIP)
-
Search engine (minimax / alpha-beta, WIP)
This project is automatically tested with GitHub Actions. Unit tests are executed on every push and pull request.
Move generation is validated using perft tests. 👉 Perft results reference
To improve performance and speed up perft tests, several optimizations have been implemented:
-
Bitboards: 64-bit masks to represent the board, enabling fast operations with bitwise logic.
-
Precomputed tables: cached attacks for "normal" pieces (knight, pawn, king) and magic bitboards for sliding pieces (rook, bishop, queen).
-
Multi-threaded perft: parallelized tree exploration to take advantage of multi-core CPUs.
-
Reduced dynamic allocations: use of preallocated arrays (Move move_list[MAX_MOVES]) to avoid unnecessary memory overhead.
Single-thread speed: 8–10 million moves/s
Multi-thread speed: 40–90 million moves/s
(
Planned improvements and features to make the engine stronger and more complete:
-
Implement iterative deepening
-
Add alpha-beta pruning
-
Introduce move ordering (killer moves, history heuristic)
-
Material and piece-square tables
-
King safety and pawn structure evaluation
-
Mobility and control of the center
-
Store already-evaluated positions using Zobrist hashing
-
Reduce redundant calculations in search
- Allow communication with GUIs such as Arena, Cute Chess, or lichess-bot