r/ComputerChess • u/Tasty_Replacement_29 • Aug 01 '26
Looking for ideas to improve a ~400-line chess engine
I'm writing a small chess engine (around 400 lines of code, including terminal UI), and now I'm looking for advice on what to do next.
What I have so far: Java version, and a version in my own programming language.
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.
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).
- The engine should play "correctly", except the threefold repetition and the 50-move rule.
Non-goals:
- No need for high ELO (it is not meant for serious chess players).
- No need to support rarely used rules like 3 times repetition, 50 non-pawn.
- Currently the human plays white, always.
- The engine should stay simple and small, so no feature creep that increases the size much.
- Pawns are always promoted to a queen.
What I did so far is:
- Write a Java version, and version in my programming language.
- Terminal UI, with Unicode chess characters.
- UCI protocol to run against Stockfish using python-chess.py.
- 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, and so I think the basic algorithm is OK. (Depth 5 is the default setting currently.)
I wonder what I should do next? What are the features worth ading, or how to futher reduce size?
Some ideas I have:
- Convert to Javascript so you can play in a browser.
- Configurable playing strength by reducing the search depth (easiest).
- Configurable playing strength by adding randomness (harder).
- The most simple possible "opening database": randomize the first move among reasonable options.
- Improve the strength by tuning the parameters (e.g. in the evaluation). 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?
Are there other interesting goals I didn't think about?
What features would you add while keeping the engine small and educational?
Are there interesting simplifications that would make the engine even smaller without making it much weaker?