CederChess - a chess engine by Claus Cederberg
CederChess is a chess engine written in the C++ programming language. It is an ungoing project, and hopefully the future versions will become better and better.
It all started many years ago when I was a student. Me and a co-student wrote a chess engine called ChickenChess in the start 1990s. All programs we wrote at that time was called something starting with "Chicken", because of the chicken scenes in the movie Back to the Future. The engine wasn't particulary good, but we passed the examination.
Then around 2014 or so, I read a paper describing an engine where the evaluation score only depended on material and positions, nothing else. I think it was this: Simplified Evaluation Function
Then in 2022, I was again interested in chess and chess engines and decided to rewrite the Java program to a C program and get it on CCRL Blitz. The rewriting took some effort, because I also wanted it to be faster and have a slightly better evaluation function, and I haven't wrote a single C line in around 25 years. It was first in 2023, I dared to send in the program (cederchess1), and now it is on the CCRL Blitz with a first initial ELO rating of 1203 - later adjusted to 1027 after changes in ELO calculation. Here is the PGN file with all 510 games played by the CCRL team in order to get that rating.
CederChess 2 (18. January 2024)
This version is the latest version with 1220 ELO (30. August 2024). There are no know issues with this version. Main changes from version 1 are:
- Generally a more clean source code.
- C++, but still a C like program where char pointer and arrays has been replaced by std::string and int has been replaced by "int_fast" types. std::vector and std::map is also used.
- Working detection of threefold repetition, so it is avoided in good positions and embraced in bad positions.
- Quiescence search until all captures has been resolved, or until a maximum depth is reached.
- Sort moves during search to help alpha-beta pruning.
- Added king safety in the evaluation method.
- Command line argument log. If left time on the clock is lesser than given thresholds, then search depth is decreased. If log is specified on the command line, the file log.txt will contain information about all the search depth decreases.
- Command line argument random MAX,DEC,MIN - if specified MAX will override RANDOM_MAX_DEFAULT define in the cpp program, DEC will override RANDOM_DEC_DEFAULT define in the cpp program, and MIN will override RANDOM_MIN_DEFAULT 4 in the cpp program.
Source code: cederchess2.cpp - compile with "g++ cederchess2.cpp -O3 -o cederchess2"
CederChess 1 (12. August 2023)
First version. Highlights:
- A single file program with less than 1700 lines of code.
- Uses UCI (Universal Chess Interface) protocol.
- The evaluation function is mainly based on material and positions.
- Search for best move is done by the Minimax algorithm with alpha-beta pruning
Known issues:
- Detecting of threefold repetition is broken.
- Once in a while the engine tries to promote an officer to a queen.
- Originally the engine stopped execution, when it was compiled to a 64-bit architecture. There is a small hack in this versions so it now works.
Source code: cederchess1.c - compile with "gcc cederchess1.c -O3 -o cederchess1"