Matthies / RubiChess

Another chess engine
GNU General Public License v3.0
155 stars 17 forks source link

Another 3-fold-blunder #407

Closed Matthies closed 1 year ago

Matthies commented 1 year ago

https://www.chess.com/computer-chess-championship#event=openbench-interlude-8-all-hands&game=321 6-men-tablebase, many threads position startpos moves e2e4 c7c6 d2d4 d7d5 f2f3 e7e6 b1c3 f8b4 c1d2 g8f6 e4e5 f6d7 f3f4 c6c5 c3b5 b4d2 d1d2 e8g8 c2c3 c5d4 c3d4 b8c6 g1f3 d7b6 b5d6 a8b8 h2h4 c8d7 h4h5 h7h6 g2g4 f7f6 f3h4 b6c8 h4g6 c8d6 e5d6 f8f7 e1c1 d7e8 c1b1 d8d6 g4g5 f6f5 d2f2 f7c7 f1b5 g8h7 f2g3 c6a5 b5e8 b8e8 g6e5 d6f8 h1e1 a5c4 e5c4 d5c4 g5g6 h7g8 e1e5 f8d6 d4d5 c4c3 b2c3 c7c5 b1a1 e8d8 g3e1 c5d5 d1d5 e6d5 e5e8 d8e8 e1e8 d6f8 e8e6 g8h8 e6d5 f8c8 a1b2 a7a6 b2b3 c8c7 d5f5 c7b6 b3c4 b6c7 c4d4 c7d8 f5d5 d8b8 f4f5 b8f4 d4d3 f4g3 d3d4 g3f4 d4d3 f4g3 d3c4 g3c7 c4b3 c7b6 b3a3 b6c7 a3b3 c7b6 b3a4 b6c7 Rubi played a4b3 which is a 3-fold.

Matthies commented 1 year ago
555605 >Rubi(0): position startpos moves e2e4 c7c6 d2d4 d7d5 f2f3 e7e6 b1c3 f8b4 c1d2 g8f6 e4e5 f6d7 f3f4 c6c5 c3b5 b4d2 d1d2 e8g8 c2c3 c5d4 c3d4 b8c6 g1f3 d7b6 b5d6 a8b8 h2h4 c8d7 h4h5 h7h6 g2g4 f7f6 f3h4 b6c8 h4g6 c8d6 e5d6 f8f7 e1c1 d7e8 c1b1 d8d6 g4g5 f6f5 d2f2 f7c7 f1b5 g8h7 f2g3 c6a5 b5e8 b8e8 g6e5 d6f8 h1e1 a5c4 e5c4 d5c4 g5g6 h7g8 e1e5 f8d6 d4d5 c4c3 b2c3 c7c5 b1a1 e8d8 g3e1 c5d5 d1d5 e6d5 e5e8 d8e8 e1e8 d6f8 e8e6 g8h8 e6d5 f8c8 a1b2 a7a6 b2b3 c8c7 d5f5 c7b6 b3c4 b6c7 c4d4 c7d8 f5d5 d8b8 f4f5 b8f4 d4d3 f4g3 d3d4 g3f4 d4d3 f4g3 d3c4 g3c7 c4b3 c7b6 b3a3 b6c7 a3b3 c7b6 b3a4 b6c7
555847 >Rubi(0): isready
555910 <Rubi(0): readyok
555910 >Rubi(0): go wtime 2040 btime 5664 winc 2000 binc 2000
555970 <Rubi(0): info depth 1 seldepth 2 multipv 1 time 0 score cp 485 nodes 34 nps 174294 tbhits 0 hashfull 0 pv a4b4 
555970 <Rubi(0): info depth 2 seldepth 3 multipv 1 time 0 score cp 547 nodes 140 nps 483960 tbhits 0 hashfull 0 pv d5e6 c7d8 
555970 <Rubi(0): info depth 4 seldepth 5 multipv 1 time 0 score cp 582 nodes 389 nps 1058169 tbhits 0 hashfull 0 pv d5e6 c7d8 a4b4 d8f8 b4b3 
555970 <Rubi(0): info depth 6 seldepth 7 multipv 1 time 0 score cp 581 nodes 2504 nps 3480871 tbhits 0 hashfull 0 pv a4b4 c7e7 b4c4 b7b5 c4b3 e7f8 
555971 <Rubi(0): info depth 7 seldepth 9 multipv 1 time 1 score cp 606 nodes 6563 nps 6219485 tbhits 0 hashfull 0 pv c3c4 c7e7 d5e6 e7d8 a4b4 b7b5 b4c5 
555971 <Rubi(0): info depth 8 seldepth 11 multipv 1 time 1 score cp 853 nodes 10204 nps 8036164 tbhits 0 hashfull 0 pv d5e6 c7d8 a4b3 d8g8 e6g8 h8g8 b3b4 g8f8 b4c5 f8e7 
555971 <Rubi(0): info depth 9 seldepth 11 multipv 1 time 1 score cp 727 nodes 27840 nps 15004139 tbhits 0 hashfull 0 pv d5e6 c7d8 a4b3 b7b5 b3b4 d8f8 b4a5 b5b4 f5f6 g7f6 
555972 <Rubi(0): info depth 10 seldepth 15 multipv 1 time 2 score cp 1041 nodes 50467 nps 21215746 tbhits 0 hashfull 0 pv a4b4 c7e7 b4b3 e7c7 d5d4 h8g8 d4c4 c7c4 b3c4 g8f8 c4c5 f8e7 c5b6 e7d8 
555974 <Rubi(0): info depth 11 seldepth 16 multipv 1 time 3 score cp 1007 nodes 118021 nps 32831472 tbhits 0 hashfull 0 pv d5d4 h8g8 a4b4 c7e7 b4b3 e7c7 d4c4 c7c4 b3c4 g8f8 c4d5 f8g8 d5e6 b7b5 e6e7 
555976 <Rubi(0): info depth 12 seldepth 17 multipv 1 time 6 score cp 1693 nodes 373048 nps 56595415 tbhits 2 hashfull 1 pv a4b4 c7e7 b4b3 e7c7 d5e6 c7d8 b3b4 a6a5 b4b5 a5a4 f5f6 g7f6 e6f7 d8d7 f7d7 h8g8 
555978 <Rubi(0): info depth 13 seldepth 24 multipv 1 time 8 score cp 1409 nodes 611040 nps 75557929 tbhits 8 hashfull 1 pv a4b4 c7b6 b4a3 b6c7 a3a4 c7f4 d5d4 f4d4 c3d4 h8g8 a4a5 g8f8 d4d5 f8e7 a5b6 a6a5 b6c7 e7f6 d5d6 f6f5 
555980 <Rubi(0): info depth 14 seldepth 20 multipv 1 time 10 score cp 1290 nodes 991580 nps 95714129 tbhits 95 hashfull 1 pv a4b4 c7b6 b4a3 b6c7 a3a4 c7f4 d5d4 f4d4 c3d4 h8g8 a4a5 g8f8 d4d5 f8e7 a5b6 a6a5 b6c7 e7f6 d5d6 
556030 <Rubi(0): info depth 15 seldepth 22 multipv 1 time 11 score cp 1345 nodes 1110894 nps 100622123 tbhits 237 hashfull 2 pv a4b4 c7b6 b4a3 b6c7 a3a4 c7f4 d5d4 f4d4 c3d4 h8g8 d4d5 g8f8 a4a5 f8e7 a5b6 a6a5 a2a4 e7d6 f5f6 g7f6 g6g7 
556030 <Rubi(0): info depth 18 seldepth 16 multipv 1 time 20 score cp 1665 nodes 2304463 nps 115097923 tbhits 2696 hashfull 2 pv a4b4 
556030 <Rubi(0): info depth 19 seldepth 46 multipv 1 time 39 score cp 2778 nodes 4920551 nps 124315407 tbhits 10156 hashfull 3 pv a4b4 c7b6 b4a3 b6c7 a3a4 c7c8 d5e6 b7b5 a4b3 c8g8 e6g8 h8g8 c3c4 g8f8 c4b5 f8e7 b5a6 e7f6 a6a7 f6g5 a7a8q g5g4 a8c8 g4g3 c8c3 g3g4 f5f6 g4f5 f6g7 f5g5 g7g8q g5h5 
556030 <Rubi(0): info depth 20 seldepth 44 multipv 1 time 47 score cp 1843 nodes 6034150 nps 126328615 tbhits 16908 hashfull 3 pv d5e6 c7d8 a4b4 d8f8 b4c4 f8d8 c4b3 b7b5 b3c2 b5b4 f5f6 g7f6 e6f7 b4b3 a2b3 d8g8 f7f6 g8g7 f6d8 g7g8 d8g8 h8g8 c3c4 g8f8 c4c5 f8g8 c2d3 a6a5 c5c6 a5a4 c6c7 a4a3 c7c8q g8g7 c8c7 g7f6 c7f4 f6e7 f4f7 e7d6 f7f8 d6d5 f8a3 
556066 <Rubi(0): info depth 21 seldepth 54 multipv 1 time 96 score cp 2356 nodes 14591475 nps 151666123 tbhits 72831 hashfull 6 pv a4b4 c7c8 b4b3 c8c7 d5f7 c7d8 b3a4 b7b5 a4b4 d8d6 b4a5 d6d8 a5a6 b5b4 f5f6 d8f6 f7f6 g7f6 c3b4 f6f5 b4b5 h8g7 b5b6 g7f6 b6b7 f5f4 a2a4 f6g5 g6g7 g5f5 g7g8q f5e4 b7b8q 
556145 <Rubi(0): info depth 22 seldepth 68 multipv 1 time 174 score cp 1903 nodes 35931857 nps 205503993 tbhits 196370 hashfull 10 pv a4b4 c7e7 b4a5 e7c7 a5a4 c7b8 d5f7 b8c8 a4b3 c8d8 f7e6 b7b5 e6a6 d8d5 b3a3 d5d8 a3b4 d8f8 b4b3 f8d8 a6b5 d8c8 c3c4 h8g8 b3b4 c8f8 b4a5 f8a3 a5b6 g8f8 b5c5 a3c5 b6c5 f8g8 c5d6 g8f8 c4c5 f8e8 c5c6 e8d8 f5f6 d8c8 f6f7 
556204 <Rubi(0): info depth 23 seldepth 82 multipv 1 time 233 score cp 2161 nodes 54048790 nps 231620475 tbhits 308656 hashfull 16 pv a4b4 c7b6 b4a4 b6c7 d5e6 c7d8 a4b4 d8f8 b4c4 f8d8 c4c5 d8c7 c5d5 c7d8 d5c4 d8c7 c4b3 c7d8 e6f7 d8b6 b3c4 b6c6 c4d4 c6d6 
556204 <Rubi(0): info depth 24 seldepth 24 multipv 1 time 233 score cp 2229 lowerbound nodes 54240153 nps 231851962 tbhits 309723 hashfull 16 pv d5e6 
556216 <Rubi(0): info depth 24 seldepth 56 multipv 1 time 246 score cp 2818 nodes 58059554 nps 235879317 tbhits 333107 hashfull 17 pv d5e6 c7d8 a4b4 d8f8 b4b3 f8g8 e6f7 g8b8 f5f6 b8g8 f7g8 h8g8 f6f7 g8f8 b3a4 f8e7 a4a5 b7b5 a5a6 b5b4 c3c4 e7e6 f7f8q e6e5 f8g7 e5e4 g7b7 e4d4 b7b4 d4d3 g6g7 d3c2 g7g8q 
556221 <Rubi(0): info depth 25 seldepth 29 multipv 1 time 251 score cp 2567 upperbound nodes 59748603 nps 237610568 tbhits 342594 hashfull 18 pv d5e6 c7d8 
556232 <Rubi(0): info depth 25 seldepth 48 multipv 1 time 261 score cp 4074 lowerbound nodes 63089971 nps 240923709 tbhits 360985 hashfull 19 pv a4b4 
556738 <Rubi(0): info depth 25 seldepth 76 multipv 1 time 766 score cp 3816 lowerbound nodes 255900272 nps 334061348 tbhits 2188223 hashfull 46 pv d5e6 
556825 <Rubi(0): info depth 25 seldepth 68 multipv 1 time 853 score cp 2879 nodes 290430888 nps 340375790 tbhits 2577486 hashfull 57 pv d5e6 c7d8 a4b4 d8f8 b4c4 f8b8 c4c5 b8c7 
557109 <Rubi(0): info depth 26 seldepth 76 multipv 1 time 1138 score cp 4121 lowerbound nodes 401389051 nps 352517512 tbhits 3690353 hashfull 73 pv d5e6 
557280 <Rubi(0): info depth 26 seldepth 68 multipv 1 time 1309 score cp 5406 lowerbound nodes 467006169 nps 356589388 tbhits 4320233 hashfull 85 pv d5e6 
557605 <Rubi(0): info depth 26 seldepth 80 multipv 1 time 1634 score cp 29855 nodes 584803194 nps 357845589 tbhits 5555424 hashfull 102 pv d5e6 c7d8 a4b4 d8f8 b4c4 f8b8 e6d7 b8g8 d7f7 g8c8 c4d4 b7b6 f5f6 c8c5 d4e4 c5c6 e4e5 c6c5 e5e6 c5c6 e6f5 c6b5 f5f4 b5g5 f4e4 g5g4 
557910 <Rubi(0): info depth 27 seldepth 72 multipv 1 time 1940 score cp 0 nodes 687976297 nps 354604730 tbhits 6499871 hashfull 132 pv d5e6 c7d8 
557910 <Rubi(0): bestmove a4b3

Seems that search drops to score 0 with move d5e6 and then thread voting switches to another thread with move a4b3 with same score and "better" depth. Should be investigated why search drops to score 0 which can be reproduced sometimes.

Matthies commented 1 year ago

Repro with 8 threads and repeating search on the position:

...
info depth 33 currmove d5e6 currmovenumber 1
info depth 33 seldepth 57 multipv 1 time 20000 score cp 29843 nodes 352230659 nps 17611514 tbhits 4852341 hashfull 727 pv f5f6
bestmove d5e6 ponder c7d8
go wtime 50000 winc 20000
info depth 37 seldepth 1 multipv 1 time 0 score cp 0 nodes 0 nps 17611514 tbhits 0 hashfull 0 pv a4b3
...

Seems that the 3fold draw came from TT.

Matthies commented 1 year ago

And a repro identical to the CCC log:

...
info depth 28 seldepth 90 multipv 1 time 4909 score cp 2446 upperbound nodes 79506773 nps 16195940 tbhits 674839 hashfull 312 pv d5e6 c7d8
info depth 28 currmove d5e6 currmovenumber 1
info depth 28 seldepth 74 multipv 1 time 5932 score cp 17349 lowerbound nodes 96372884 nps 16245032 tbhits 781494 hashfull 357 pv d5e6
info depth 28 currmove d5e6 currmovenumber 1
info depth 28 seldepth 117 multipv 1 time 20000 score cp 0 nodes 288273423 nps 14413576 tbhits 2555380 hashfull 819 pv d5e6
bestmove a4b3
Matthies commented 1 year ago

Okay, main problem seems that rootsearch in helper threads doesn't check for immediate stop (CheckForImmediateStop() only stops for main thread) but finishes the move loop (getting wrong scores from alphabeta which does check for immidiate stop) and even writes this wrong results to the tt.

Matthies commented 1 year ago

Fixed with #408