Show HN: Sameshi – a ~1200 Elo chess engine that fits within 2KB (github.com)
I made a chess engine today, and made it fit within 2KB.
I used a variant of MinMax called Negamax, with alpha beta pruning. For the board representation I have used a 120-cell "mailbox". I managed to squeeze in checkmate/stalemate in there, after trimming out some edge cases.
I am a great fan of demoscene (computer art subculture) since middle school, and hence it was a ritual i had to perform.
For estimating the Elo, I measured 240 automated games against Stockfish Elo levels (1320 to 1600) under fixed depth-5 and some constrained rules, using equal color distribution.
Then converted pooled win/draw/loss scores to Elo through some standard logistic formula with binomial 95% confidence interval.
27 comments
[ 2.7 ms ] story [ 59.0 ms ] threadDo you work with it like this or do you have some sort of script you apply to get it down to a single line, single letter variable names?
P.S. I assume 1200 elo in chess com scale (not lichess / fide elo) and bullet chess variant?
Bug report:
The pawn is not permitted to move two fields after it has already beeen moved once before: b6b4 isn't a valid move after b7b6. (First moving two fields, and then one would have been okay, in contrast.)As you write: not implemented: castling, en passant, promotion, repetition, 50-move rule - those are all required to call the game being played modern chess.
I could see an argument for skipping repetition and 50-move rule for tiny engines, but you do need castling, en pessant and promotion for pretty much any serious play.
https://en.wikipedia.org/wiki/Video_Chess fit in 4k and supported fuller ruleset in 1980 did it not?
So I would ask what is the smallest fully UCI (https://www.chessprogramming.org/UCI) compliant engine available currently?
This would be a fun goal to beat - make something tiny that supports full ruleset.
PS my first chess computer in early 1980s was this: https://www.ismenio.com/chess_fidelity_cc3.html - it also supported castling, en pessant, not sure about 50 move rule.
[1] https://cutechess.com/
[2] https://www.chessprogramming.org/Sequential_Probability_Rati...
[3] https://github.com/michiguel/Ordo
[1] https://github.com/thomasmueller/bau-lang/blob/main/src/test...
> Not implemented: castling, en passant, promotion, repetition, 50-move rule.