]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Use cycle detection to bound search value
[stockfish] / src / search.cpp
index 1a4f654d10539a998cc248a5fa5c0c2d2f0eade9..025c1141c97546e6e98693877fad9afff26336d5 100644 (file)
@@ -577,6 +577,17 @@ namespace {
         beta = std::min(mate_in(ss->ply+1), beta);
         if (alpha >= beta)
             return alpha;
+
+        // Check if there exists a move which draws by repetition, or an alternative
+        // earlier move to this position.
+        if (   pos.rule50_count() >= 3
+            && alpha < VALUE_DRAW
+            && pos.has_game_cycle(ss->ply))
+        {
+            alpha = VALUE_DRAW;
+            if (alpha >= beta)
+                return alpha;
+        }
     }
 
     assert(0 <= ss->ply && ss->ply < MAX_PLY);