A chess engine written in C# as a hobby project.
Affinity Chess is developed with the following basic concepts:
🔹 Written from scratch in C#.
🔹 Bitboard representation with magic bitboards for sliding pieces.
🔹 Pseudo legal move generation for quiet- and capturing moves separately.
🔹 Make/unmake move approach.
🔹 Incremental Zobrist hashing.
🔹 A standard Negamax framework with alpha/beta pruning for search.
🔹 UCI protocol for communication with GUIs.
Version 1.0 has the following features implemented:
✔️ Iterative deepening
✔️ Principal variation search
✔️ Quiescence search
✔️ Delta pruning (in Quiescence search)
✔️ Transposition table
✔️ Null move pruning
✔️ Mate distance pruning
✔️ Razoring
✔️ Late move reduction
✔️ Check extension
✔️ Basic evaluation function based on PeSTO
The evaluation function in version 1.0 is only based on piece square tables. Future evaluation functions will include more concepts such as pawn structure, open files and king safety.
In the search function all moves are generated and sorted before tested in the recursive loop. Since the first few moves often leads to a cutoff there is a lot of unnecessary work done with sorting the list on before hand. Future versions will look into staged move generation where the best moves are generated and tried first, and only if they fail are the rest of the moves generated.
Move generation and the make/unmake move functions are working, but are relatively slow. The speed in this version is around 1,2 million NPS during Pertf testing. Since these functions are crucial for the NPS speed they will be more optimized in future versions.
Too many percent of search is now spent in quiescence search. Future versions will try to reduce this to get a better branching factor and therefore search fewer nodes.
Download the release you want to use from the release page. You can then install the engine in your favourite Chess GUI (e.g. Arena or Cute Chess) and play against it from there.
Please let me know if you find any bugs with the engine, or if you need any support in how to set it up. Also let me know if there are any features you are currently missing and I will try to implement them in coming versions.
A lot of inspiration for the transposition tables are taken from Leorik.
Inpiration for the magic bitboard approach was taken from Cosette and the YouTube series from Maksim Korzh.
Huge thanks also to the TalkChess community for helping me out along the way, I wouldn't have gotten this far without you.