Since you’re here...

We hope you will consider supporting us today. We need your support to continue to exist, because good entries are more and more work time. Every reader contribution, however big or small, is so valuable. Support "Chess Engines Diary" even a small amount– and it only takes a minute. Thank you.
============================== My email: jotes@go2.pl



Chess engine: Tofiks 1.3.0



Tofiks - UCI chess engine
Rating CEDR=2256

v.1.3.0:
Score from 32bit to 16bit and Move from 16bit to 32bit. I decided to change up the types of the data my engine uses internally. I shifted 16bits from evaluation score used by the search towards the move type. 16bits is plenty to calculate scores for search with more than sufficient granularity. However, certain actions like finding the bitboard of the piece moved or determining if the move is a capture take significant calculation. This information is now also included in the Move type along with flags for isCastling, isDoublePawnPush.

While this change significantly slowed down my move generation it did speed up the make move functionality. The trade-off advantage for now seems minor but there are probably more potential speed up's available to be discovered. Also I still have 10bits unused from the 32.

Threefold repetition downgraded to twofold repetition
Threefold repetition I believe is just a human rule so that games do not accidentally and abruptly end in a draw when they shouldn't. But logically it does not make sense. If we assume we always play the best moves and the best moves only then if a position repeated itself twice there should be no logical reason it should not repeat itself thrice. Checking for 2-fold repetition is of course significantly cheaper than 3-fold. But I also discovered that the engine could not see three fold repetition draws from a distance because the transposition table would not permit the same position to be played out thrice. When we first repeat a position that is by definition a transposition to the initial position and a transposition table should be able to see that. So I noticed that I never hit the threefold repetition rule. I tested this in a completely lost position where the only way out is to check the enemy king any other move leads to instant mate. While the engine saw the mate and avoided it by delivering checks it could actually not determine that it was actually a draw but gave the evaluation still as favoring the opposition.

Tests, tests, tests... and fix some bugs
Like the threefold to twofold repetition bug was discovered by a test, some other bugs were too. I found a small inconsistency where white bishops would be valued more than black bishops. This is due to having a bug in eval - I entered a lot of positions which I evaluated without any further search. Flipped the colors and the side to move to represent the same position with swapped colors. And I found that in some circumstances the symmetry was broken and there was a bias in the colors.

Overall I had neglected tests for too long in my development. I have built a small and non-comprehensive list of tests:

Perft 6 positions from Chess Programming Wiki Perft results
Mate a small collection of mates from mate in 3 to mate in 6
PV correctness - check if the reported PV actually represents valid moves
Draw by repetition and forcing a draw in a otherwise lost game
Evaluation symmetry
Fuzz testing for encoding and decoding information to the transposition hash table
This is a small list and there positions in each are not exhaustive but it still has helped me with development speed due to the ability to making bold changes and simply re-running the tests and giving me a baseline confidence that it still functions mostly as it should.

Results
I played a round robin tournament with versions 1.0 through 1.3 to determine their relative strengths.

Rank Name                          Elo     +/-   Games    Wins  Losses   Draws   Points   Score    Draw   White   Black 
   1 tofiks-1.3                    182      27     600     378      89     133    444.5   74.1%   22.2%   74.8%   73.3% 
   2 tofiks-1.2                    108      25     600     315     134     151    390.5   65.1%   25.2%   69.2%   61.0% 
   3 tofiks-1.1                    -28      24     600     202     250     148    276.0   46.0%   24.7%   46.3%   45.7% 
   4 tofiks-1.0                   -304      35     600      57     479      64     89.0   14.8%   10.7%   15.3%   14.3% 
Given 3 weeks of development I am quite happy with the progress I have made.





Comments