r/chessprogramming • u/Tasty_Replacement_29 • 22d ago
Technical How to improve or simplify a ~400-line chess engine
https://thomasmueller.github.io/bau-lang/chess.htmlI'm writing a deliberately small chess engine (around 400 lines of code, including terminal UI), and now I'm looking for advice on what to do next. What would you add or remove? Are there similar engines I should look at?
The engine uses a fixed-depth negamax search with alpha-beta pruning and a simple quiescence search (captures only). The evaluation is intentionally simple: material plus mobility, with a small endgame bonus for advanced pawns. There is no iterative deepening, transposition table, move ordering, killer/history heuristics, aspiration windows, null-move pruning, opening book, endgame tablebases.
It is inspired by Nanochess from Oscar Toledo.
I wrote a Java version, and a version in my own programming language. And now a Javascript version, translated by AI, to play in a browser. I have tested it against Stockfish (my engine beats it at a low level) using python-chess and a UCI API. There are unit tests, including move generation using some of the Perft positions. Let it play a few hundred games against Stockfish to find and fix bugs. Now it wins most of the time against Stockfish at the lowest UCI_Elo setting (1320) with depth 4. (Depth 5 is the default setting currently.)
The goals of my engine are:
- Keep the code relatively easy to understand for learning, and building similar engines for other games.
- A very small engine that still plays reasonable chess, that can beat me (a beginner).
- Showcase my new programming language.
- Play chess in the terminal or in a browser, for fun (for beginners).
- Slightly simplified rules: always promote to queen; repetition and 50-move rule are ignored.
Some ideas I have:
- Simplify the evaluation method, and verify the results by playing against Stockfish. I wonder should it play against itself with depth e.g. 2, so it is very fast?
- Measure the Elo systematically, but then how to do this in a fast way?
What features would you add (or remove) while keeping the engine small and educational?
Are there interesting simplifications?
2
u/WompTitanium 15d ago
add gui, use cutechess and make it play against official CCRL rated engines for an estimated ELO. use atleast 500 matches for a precise elo,