I agree that saving a hash value during the move loop isn't very useful. I've moved it to the end of the function as Joost recommends in their pseudocode.
I've also added simple move ordering, based on hash, SEE, killers and history.
For some reason, the search is still as slow as before, even though everything about the transposition table looks like it's being implemented correctly: The hashfull function shows that the table is definitely filling up, and the hash hit rate (successful probes / total probes) is almost 100%, but still the search is taking far longer than expected, and the engine doesn't find a winning score.
Code: Select all
position fen 8/k7/3p4/p2P1p2/P2P1P2/8/8/K7 w - -
go infinite-
info depth 1 score cp 63 time 0 nodes 7 nps 7000 hashfull 1 hashhitrate 0 mbf 7 betacutoff nan pv a1b2
info depth 2 score cp 23 time 60 nodes 31 nps 0 hashfull 4 hashhitrate 0.2 mbf 6.2 betacutoff 1 pv a1b2 a7b7
info depth 3 score cp 55 time 118 nodes 116 nps 0 hashfull 11 hashhitrate 0.388889 mbf 6.44444 betacutoff 1 pv a1b2 a7b7
b2c3
info depth 4 score cp 55 time 175 nodes 396 nps 2000 hashfull 38 hashhitrate 0.536585 mbf 4.82927 betacutoff 0.962264 pv
a1b2 a7b6 b2c3 b6b7
info depth 5 score cp 55 time 236 nodes 1097 nps 4000 hashfull 65 hashhitrate 0.70852 mbf 4.91928 betacutoff 0.923729 pv
a1b2 a7b6 b2c3 b6a6 c3b3
info depth 6 score cp 54 time 305 nodes 2864 nps 9000 hashfull 126 hashhitrate 0.839695 mbf 3.64377 betacutoff 0.83592 p
v a1b2 a7b7 b2c3 b7c8 c3b3 c8c7
info depth 7 score cp 56 time 364 nodes 6707 nps 18000 hashfull 176 hashhitrate 0.904273 mbf 3.62737 betacutoff 0.876673
pv a1b1 a7a6 b1c2 a6b6 c2c3 b6a6 c3d2
info depth 8 score cp 55 time 428 nodes 16099 nps 37000 hashfull 239 hashhitrate 0.954657 mbf 3.04156 betacutoff 0.92408
5 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7d7 d3e3 d7e7
info depth 9 score cp 55 time 491 nodes 37328 nps 75000 hashfull 272 hashhitrate 0.972563 mbf 3.75156 betacutoff 0.95101
8 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7d7 d3c4 d7e7 c4c3
info depth 10 score cp 55 time 560 nodes 81243 nps 144000 hashfull 322 hashhitrate 0.987777 mbf 3.07261 betacutoff 0.982
789 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6a7
info depth 11 score cp 55 time 639 nodes 240951 nps 376000 hashfull 366 hashhitrate 0.993847 mbf 4.03745 betacutoff 0.99
0478 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4
info depth 12 score cp 55 time 759 nodes 552102 nps 726000 hashfull 411 hashhitrate 0.997682 mbf 3.1047 betacutoff 0.997
195 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4 b6a6
info depth 13 score cp 55 time 958 nodes 1728824 nps 1802000 hashfull 464 hashhitrate 0.998868 mbf 4.19946 betacutoff 0.
998471 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4 b6a6 c4d3
info depth 14 score cp 55 time 1430 nodes 3877820 nps 2709000 hashfull 545 hashhitrate 0.999561 mbf 3.11021 betacutoff 0
.999475 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4 b6a6 c4d3 a6b6
info depth 15 score cp 55 time 2403 nodes 12036898 nps 5007000 hashfull 682 hashhitrate 0.999754 mbf 4.30728 betacutoff
0.999588 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4 b6a6 c4c3 a6b6 c3c4
info depth 16 score cp 55 time 5326 nodes 26802503 nps 5031000 hashfull 920 hashhitrate 0.999892 mbf 3.13075 betacutoff
0.9998 pv a1b1 a7b6 b1c2 b6c7 c2d3 c7b6 d3c4 b6a6 c4d3 a6b6 d3c4 b6a6 c4c3 a6b6 c3b3 b6a7
Is this usually caused by hash cutoffs not working correctly, or is it an issue with move ordering? Everything seems like it's working but the search still doesn't find the win.
I've updated the repository with my new code:
https://github.com/konsolas/ToppleChess