Hello Sven,
Yes, I miss some of your questions.
When this bug occurred could not be traced. I wanted to check if my older sources also have this bug. For a very long time, I have been using this method of having mate_search(). I lost my really old codes, threw away the CD's when I change to usb pen-drive. So the older versions now available too had this bug.
I did a match cowrie-stockfish and extracted a clearly winning position. Then I let my program play the winning side with TT enabled. I replayed the same position 6/7 times and each time, my program would win and mate. Because both programs did not clear the TT, the games are all clearly different; stockfish gets smarter with each game and I show the log for the last game. Notice that from move 36, it detected mate score 7981; after that, mate_search() takes over
and the mate-distance decreased exactly by one after every move - 7991/7993/7995/7997/7999, checkmate.
So it shows that under 'usual circumstances', my program played the position in 6/7 ways and did not concede a draw by mistake. Actually I trust my engine is generally very well debugged through many, many asserts.
"r6r/Pp1b2q1/2pk1p2/R5p1/P2P4/1QPB1NPp/5P1P/4R1K1 w - - 8 34"
35 f3e5 score( 2052) depth( 7) pvL(11) ply(18) nps( 1747626) pc(11) cttime(10) ctpoll(0)
sec(0.48, used 0.38) nodes(q 2.7%, h 62.2%, f 35.1%) FH(53.5%) evasion(25.4%) invalid(10.6%)
Root-red(30.12%, rsc 0.00%) Root-research(1.20%) BranchF(1.10%)
Hash-hit(full 55.8%, qs 6.3%, p( 100.0%, cover 0.0%), ev (29.3%) matOWrite( 73.71) draw(0)
ext(8.94%) see(qs 2.45%, delay 45.45%) zero-wnd(29.95%, rsc 0.60%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(8.06%)
EV call(59.53%) lazy(0.00%) cut(0.00%) fl(0.00%)
35 d7c8
node-mask, timeout 0x1ffff, poll 0x1fffff
Number valid moves 29
!!! Opponent followPV, score(725) bestmove(a2c4)
depth start 1
36 a2c4 score( 7981) depth( 8) pvL( 1) ply(16) nps( 2127792) pc(11) cttime(18) ctpoll(0)
sec(0.41, used 0.31) nodes(q 1.4%, h 33.0%, f 65.6%) FH(14.9%) evasion(14.8%) invalid(3.3%)
Root-red(8.46%, rsc 0.00%) Root-research(1.54%) BranchF(1.09%)
Hash-hit(full 50.1%, qs 6.5%, p( 100.0%, cover 0.0%), ev (29.7%) matOWrite( 76.77) draw(0)
ext(4.89%) see(qs 1.90%, delay 13.81%) zero-wnd(15.26%, rsc 0.47%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(3.65%)
EV call(31.04%) lazy(0.00%) cut(0.00%) fl(0.00%)
36 c8f5
node-mask, timeout 0x1ffff, poll 0x3fffff
Number valid moves 30
depth start 5
Matesearch found best mate 7991, depth 10
37 c4c6 score( 7991) depth( 8) pvL( 9) ply(11) nps( 2777083) pc(12) cttime(9) ctpoll(0)
sec(0.57, used 0.12) nodes(q 0.0%, h 2.3%, f 97.7%) FH(0.4%) evasion(19.4%) invalid(0.1%)
Root-red(0.00%, rsc -nan%) Root-research(1.65%) BranchF(0.89%)
Hash-hit(full 51.5%, qs 2.9%, p( 100.0%, cover 0.0%), ev (93.0%) matOWrite( 82.85) draw(0)
ext(0.17%) see(qs 3.33%, delay 0.71%) zero-wnd(0.50%, rsc 0.49%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(0.12%)
EV call(0.16%) lazy(0.00%) cut(0.00%) fl(0.00%)
37 f5e6
node-mask, timeout 0x3ffff, poll 0x3fffff
!!! Root start with TT matesearch score 7993 d4d5
Number valid moves 33
depth start 2
Matesearch found no better mate 7993, depth 6, d4d5
38 d4d5 score( 7993) depth( 6) pvL( 1) ply( 5) nps( 2777083) pc(12) cttime(3) ctpoll(0)
sec(0.56, used 0.00) nodes(q 0.0%, h 0.0%, f 100.0%) FH(0.0%) evasion(14.1%) invalid(0.0%)
Root-red(0.00%, rsc -nan%) Root-research(0.00%) BranchF(-nan%)
Hash-hit(full 78.2%, qs -nan%, p( 100.0%, cover 0.0%), ev (-nan%) matOWrite( 5.48) draw(0)
ext(0.00%) see(qs -nan%, delay 0.00%) zero-wnd(0.00%, rsc -nan%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(0.00%)
EV call(6.50%) lazy(0.00%) cut(0.00%) fl(0.00%)
38 e6g4
node-mask, timeout 0x3ffff, poll 0x3fffff
!!! Root start with TT matesearch score 7995 c6b6
Number valid moves 30
depth start 2
Matesearch found no better mate 7995, depth 4, c6b6
39 c6b6 score( 7995) depth( 4) pvL( 1) ply( 3) nps( 2777083) pc(12) cttime(2) ctpoll(0)
sec(0.57, used 0.00) nodes(q 0.0%, h 0.0%, f 100.0%) FH(0.0%) evasion(43.1%) invalid(0.0%)
Root-red(0.00%, rsc -nan%) Root-research(0.00%) BranchF(-nan%)
Hash-hit(full 68.2%, qs -nan%, p( 100.0%, cover 0.0%), ev (-nan%) matOWrite( 42.31) draw(0)
ext(0.00%) see(qs -nan%, delay 0.00%) zero-wnd(0.00%, rsc -nan%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(0.00%)
EV call(11.05%) lazy(0.00%) cut(0.00%) fl(0.00%)
39 b8a8
node-mask, timeout 0x3ffff, poll 0x3fffff
!!! Root start with TT matesearch score 7997 e5c6
Number valid moves 36
depth start 2
Matesearch found no better mate 7997, depth 2, e5c6
40 e5c6 score( 7997) depth( 2) pvL( 1) ply( 1) nps( 2777083) pc(12) cttime(1) ctpoll(0)
sec(0.59, used 0.00) nodes(q 0.0%, h 0.0%, f 100.0%) FH(0.0%) evasion(50.0%) invalid(0.0%)
Root-red(0.00%, rsc -nan%) Root-research(0.00%) BranchF(-nan%)
Hash-hit(full 85.7%, qs -nan%, p( 100.0%, cover 0.0%), ev (-nan%) matOWrite( 50.00) draw(0)
ext(0.00%) see(qs -nan%, delay 0.00%) zero-wnd(0.00%, rsc -nan%)
null(0.0% hit -nan% verify -nan% ok -nan% ) lmr(0.00%, rsc -nan%) ply1_rsc(0) fut(0.00%) killer(0.00%)
EV call(207.14%) lazy(0.00%) cut(0.00%) fl(0.00%)
40 g4d1
node-mask, timeout 0x3ffff, poll 0x3fffff
!!! Root returns immediate - Checkmate 7999 b6a7
41 b6a7 score( 7999) depth( 0) pvL( 1) ply( 0) nps( 2777083) pc(12) cttime(1) ctpoll(0)
sec(0.61, used 0.00) nodes(q -nan%, h -nan%, f -nan%) FH(-nan%) evasion(0.0%) invalid(-nan%)
Root-red(-nan%, rsc -nan%) Root-research(-nan%) BranchF(-nan%)
Hash-hit(full -nan%, qs -nan%, p( -nan%, cover -nan%), ev (-nan%) matOWrite( -nan) draw(0)
ext(-nan%) see(qs -nan%, delay -nan%) zero-wnd(-nan%, rsc -nan%)
null(-nan% hit -nan% verify -nan% ok -nan% ) lmr(-nan%, rsc -nan%) ply1_rsc(0) fut(-nan%) killer(-nan%)
EV call(-nan%) lazy(-nan%) cut(-nan%) fl(-nan%)
Probing at the root is good for nothing IMO, and I firmly believe you should change that. But it can only be related to your current problem as far as the mate search is concerned. What does your engine do if the mate search function, when called at the root node, returns a score (and possibly a best move) that it took directly from the TT without searching?
I don't exactly understand the above.
!!! Root start with TT matesearch score 7993 d4d5
Number valid moves 33
depth start 2
Matesearch found no better mate 7993, depth 6, d4d5
38 d4d5 score( 7993) depth( 6) pvL( 1) ...
From the log above for move (38), TT probe at root had a mate score of 7993. Then mate_search() was called with:
best = alpha = 7993;
beta = INFI;
with a best move.
mate_search(), after search, confirmed it is the best mate and returns.
Best Regards,
Rasjid.