Ras wrote: ↑Tue May 16, 2023 8:51 am
If Black moves Kd8-c8, the shortest mate is Rd4-b4 Kc8-d8 Rb4-b8# (mate in 4 plies). However, Kc8-d8 is zugzwang. If you allow a nullmove here, Rb4-b8 does not work so that Black escapes from that mate. So instead after Kd8-c8, the next shortest line without zugzwang is Rd4-h4 Kc8-b8 Rb7-g7 Kb8-c8 Rh4-h8# (mate in 6 plies - still less than 10).
I think what Clayton maybe means that his engine takes a 10 ply deep search to finally catch the mate in 4 plys? I find it hard to imagine how it would miss the mate in 6 as long as null-move is not playable when STM is in check. (which should be obvious)
With all safeguards removed Leorik would never find the mate in 4 because he'd miss the Zugzwang entirely but finds the mate in 6 plies at depth 6.
Code: Select all
info depth 1 score cp -2122 nodes 3 nps 600 time 5 pv d8c8
info depth 2 score cp -2172 nodes 49 nps 2578 time 19 pv d8c8 f5e6
info depth 3 score cp -2181 nodes 199 nps 10473 time 19 pv d8e8 d4d7 e8f8
info depth 4 score cp -2283 nodes 649 nps 32450 time 20 pv d8c8 f5e6 c8b8 d4d7
info depth 5 score cp -2246 nodes 1003 nps 50150 time 20 pv d8c8 f5e6 c8b8 d4d7 b8c8
info depth 6 score mate -3 nodes 1707 nps 85350 time 20 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 7 score mate -3 nodes 2377 nps 118850 time 20 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 8 score mate -3 nodes 3558 nps 169428 time 21 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 9 score mate -3 nodes 4377 nps 208428 time 21 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 10 score mate -3 nodes 7454 nps 354952 time 21 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 11 score mate -3 nodes 10307 nps 468500 time 22 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
info depth 12 score mate -3 nodes 18661 nps 811347 time 23 pv d8c8 f5e6 c8b8 d4d7 b8c8 a7a8
The important safeguard to add is to not do NullMovePruning in "endgames" which I define as the side to move having only Kings & Pawns. (Ras definition was more inclusive)
Code: Select all
if (!inCheck && !current.IsEndgame()) DoNullmovePruning()
Code: Select all
info depth 1 score cp -2122 nodes 3 nps 600 time 5 pv d8c8
info depth 2 score cp -2172 nodes 49 nps 2578 time 19 pv d8c8 f5e6
info depth 3 score cp -2181 nodes 192 nps 9600 time 20 pv d8e8 d4d7 e8f8
info depth 4 score cp -2283 nodes 895 nps 44750 time 20 pv d8c8 f5e6 c8b8 d4d7
info depth 5 score cp -2246 nodes 1134 nps 56700 time 20 pv d8c8 f5e6 c8b8 d4d7 b8c8
info depth 6 score mate -2 nodes 2834 nps 141700 time 20 pv d8c8 d4b4 c8d8 b4b8
Now the mate exploiting Zugzwang is found quickly enough.
Another safeguard I usually add is that when the previous iteration found a mate then I disable null-moves entirely to try and find a shorter mate involving zugzwang. (The game is won already, but now let's try to win it as quickly as possible)
And last but not least I usually also don't do null-moves the first few plies e.g. not when current
ply <= searchdepth / 4