Show HN: Sameshi – a ~1200 Elo chess engine that fits within 2KB
A developer has unveiled Sameshi, a chess engine that masterfully squeezes into a mere 2KB, achieving an impressive ~1200 Elo rating despite its constrained footprint. This project, born from demoscene inspiration, showcases extreme code optimization and minimalist design. Hacker News celebrates the technical prowess, debating the implications of such compact power and the art of code minification.
The Lowdown
This Show HN entry introduces "Sameshi," a minimalist chess engine crafted to fit within an astonishing 2KB. Inspired by the demoscene subculture's focus on extreme code optimization, the creator implemented a variant of MinMax with alpha-beta pruning and a 120-cell "mailbox" board representation. The engine, which deliberately omits advanced rules like castling, en passant, promotion, and the 50-move rule, still manages to calculate checkmate and stalemate conditions.
- Size Constraint: The primary goal was to fit the entire engine, including core logic, within 2KB.
- Elo Rating: The engine achieves an estimated ~1170 Elo (with a 95% CI of 1110-1225), determined by playing 240 automated games against various Stockfish Elo levels (1320-1600) under fixed depth-5 and constrained rules.
- Technical Implementation: Utilizes Negamax with alpha-beta pruning and a 120-cell "mailbox" for board representation.
- Feature Limitations: To meet the size constraint, complex chess rules such as castling, en passant, pawn promotion, repetition draws, and the 50-move rule are not implemented.
The "Sameshi" project is a fascinating exploration into the limits of code size and efficiency, proving that significant functionality can be achieved within incredibly tight constraints, a testament to the author's ingenuity and demoscene spirit.
The Gossip
Compact Code Commentary
Commenters expressed awe and amusement at the extremely small, often minified, source code. Many praised the technical achievement of fitting a chess engine into 2KB, with some comparing it to code obfuscation or the typical output of a minifier. The discussion also touched on the trade-off between compact size and human readability, with some wishing for an unminified version and others suggesting reverse-engineering as a fun challenge.
Elo versus Engineering Efficiency
A significant portion of the discussion revolved around the engine's ~1200 Elo rating and how it scales with size. Users questioned the Elo measurement in relation to the engine's limited rule set and wondered about the potential Elo for larger engines (e.g., 4KB). This led to a fascinating debate on the "Elo:bytes" ratio and how much functionality could be packed into minimal code, with one commenter pointing out that 4KB engines can reach 3000 Elo, leading to philosophical reflections on the efficiency of artificial intelligence compared to human mastery. The author clarified how Stockfish was constrained to play within Sameshi's rule set during testing.
AI Authorship Inquiries
A few users briefly inquired if the code was generated by an AI assistant like Codex or Claude. The author swiftly and humorously dismissed these suggestions, stating that "scribbling long enough on a piece of paper is more enjoyable than prompting," emphasizing the human effort and dedication behind the project.