]> git.sesse.net Git - stockfish/commitdiff
Do not exit early even when seeing mate
authorJoona Kiiski <joona.kiiski@gmail.com>
Sat, 23 Jul 2011 21:18:28 +0000 (22:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 24 Jul 2011 05:13:29 +0000 (06:13 +0100)
Fixes the reported KNNK ending problem:

http://talkchess.com/forum/viewtopic.php?t=39347

Joona says:

Now I finally had a time to take a look at on this issue.

I've reproduced the problem starting from this position:
1B6/1B2k3/P7/1P3p2/1K6/8/4b3/4b3 w - - 6 85

I made Stockfish play as white and Fruit as black.
I repeated test ten times and once SF was not able to deliver mate.

But I observed several times that SF had reported on last something like mate in 10.
However next time it played move with score mate in 15.

Easiest way to solve the problem is attached as a patch. I tested it several times and SF always
ended up playing the optimal move. Of course the downside is that now delivering mate
takes a bit longer, but IMO it's better to lose once in a while by time in sudden death
game than not being able to deliver simple mate with long time controls.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 94b34389178f0f18119d010bea23c8bdebf3d06e..aec6434553a8c82f48908fad4183ed20ea50121d 100644 (file)
@@ -633,12 +633,6 @@ namespace {
         // Check for some early stop condition
         if (!StopRequest && Limits.useTimeManagement())
         {
-            // Stop search early when the last two iterations returned a mate score
-            if (   depth >= 5
-                && abs(bestValues[depth])     >= VALUE_MATE_IN_PLY_MAX
-                && abs(bestValues[depth - 1]) >= VALUE_MATE_IN_PLY_MAX)
-                StopRequest = true;
-
             // Stop search early if one move seems to be much better than the
             // others or if there is only a single legal move. Also in the latter
             // case we search up to some depth anyway to get a proper score.