X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=dcd4a5ed71c9a0da313343415a471205509238a0;hp=3ba0dbc905b9f6a75c4da3be45dca9b23a2d17f2;hb=ce063f59cd0fea215309c719ee56cbf486a5ea80;hpb=3cf6471738dc704ddf553d5f8d2dc9875c2ccbe7 diff --git a/src/search.cpp b/src/search.cpp index 3ba0dbc9..dcd4a5ed 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -194,7 +194,7 @@ void Search::think() { goto finalize; } - if (Options["OwnBook"] && !Limits.infinite) + if (Options["OwnBook"] && !Limits.infinite && !Limits.mate) { Move bookMove = book.probe(RootPos, Options["Book File"], Options["Best Book Move"]); @@ -410,6 +410,12 @@ namespace { if (depth > 2 && BestMoveChanges) bestMoveNeverChanged = false; + // Do we have found a "mate in x"? + if ( Limits.mate + && bestValue >= VALUE_MATE_IN_MAX_PLY + && VALUE_MATE - bestValue <= 2 * Limits.mate) + Signals.stop = true; + // Do we have time for the next iteration? Can we stop searching now? if (Limits.use_time_management() && !Signals.stopOnPonderhit) { @@ -602,6 +608,11 @@ namespace { ss->staticEval, ss->evalMargin); } + // Handling of UCI command 'mate in x moves'. We simply return if after + // 'x' moves we still have not checkmated the opponent. + if (PvNode && !RootNode && !inCheck && Limits.mate && ss->ply > 2 * Limits.mate) + return eval; + // Update gain for the parent non-capture move given the static position // evaluation before and after the move. if ( (move = (ss-1)->currentMove) != MOVE_NULL