open source · zig · uci · mit
a chess engine that loses to most humans above 2100.
alpha-beta with iterative deepening, quiescence search, transposition table, basic eval. playable via uci in any chess gui. i wrote it in zig because i wanted to learn zig and chess felt like more fun than another linked list. it's beaten me 41 times out of 50, which is either impressive or sad depending on how you count.
a b c d e f g h
┌───┬───┬───┬───┬───┬───┬───┬───┐
8 │ r │ . │ . │ q │ . │ r │ k │ . │ 8
├───┼───┼───┼───┼───┼───┼───┼───┤
7 │ p │ . │ . │ . │ . │ p │ b │ p │ 7
├───┼───┼───┼───┼───┼───┼───┼───┤
6 │ . │ p │ . │ . │ p │ . │ p │ . │ 6
├───┼───┼───┼───┼───┼───┼───┼───┤
5 │ . │ . │ . │ p │ . │ . │ . │ . │ 5
├───┼───┼───┼───┼───┼───┼───┼───┤
4 │ . │ . │ . │ P │ . │ . │ . │ . │ 4
├───┼───┼───┼───┼───┼───┼───┼───┤
3 │ . │ . │ N │ . │ . │ N │ . │ . │ 3
├───┼───┼───┼───┼───┼───┼───┼───┤
2 │ P │ P │ . │ . │ . │ P │ P │ P │ 2
├───┼───┼───┼───┼───┼───┼───┼───┤
1 │ R │ . │ . │ Q │ R │ . │ K │ . │ 1
└───┴───┴───┴───┴───┴───┴───┴───┘
a b c d e f g h
best move in 3.8s at depth 14: Nxd5
eval: +0.42 (white slightly better)
pv: Nxd5 exd5 Qxd5 Rfd8 Qc4
nodes: 2,847,113 nps: 748k
a middlegame position the engine thought about for a bit
what it does
the pieces that matter.
- bitboard representation. magic bitboards for sliding pieces. i spent two weekends on this one thing.
- alpha-beta with iterative deepening up to depth ~18 in typical middlegame.
- quiescence search for tactical stability. transposition table with zobrist hashing.
- uci protocol, so plug it into cutechess, arena, lichess-bot, whatever. i've run it on lichess under a bot account and it sits around 2080.
bench
elo over versions.
version elo (ccrl-esque local gauntlet) notes
v0.1 1340 naive, no quiescence
v0.2 1680 + quiescence
v0.3 1895 + tt, zobrist
v0.4 2080 + killer moves, lmr
v0.5 2110 + tuned pst via a long coffee-fueled weekend
gauntlet is a rotating pool of stockfish levels + a couple other toy engines, 10+0.1, on my m2.
install
not public yet.
source drops on github soon, i'm still polishing the repo. zig 0.13 or newer when it ships. email bennett@frkhd.com if you want to try it early.