]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Extend intermediate LMR to root search
[stockfish] / src / search.cpp
index 8fa1a37928399d45da5d8bf4173e7bbe20f7d08a..91b7a867603841eb9612310039ca429b21983b62 100644 (file)
@@ -892,17 +892,31 @@ namespace {
                         ss->reduction = reduction<PV>(depth, i - MultiPV + 2);
                         if (ss->reduction)
                         {
+                            assert(newDepth-ss->reduction >= OnePly);
+
                             // Reduced depth non-pv search using alpha as upperbound
                             value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction);
                             doFullDepthSearch = (value > alpha);
                         }
+
+                        // The move failed high, but if reduction is very big we could
+                        // face a false positive, retry with a less aggressive reduction,
+                        // if the move fails high again then go with full depth search.
+                        if (doFullDepthSearch && ss->reduction > 2 * OnePly)
+                        {
+                            assert(newDepth - OnePly >= OnePly);
+
+                            ss->reduction = OnePly;
+                            value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction);
+                            doFullDepthSearch = (value > alpha);
+                        }
+                        ss->reduction = Depth(0); // Restore original reduction
                     }
 
                     // Step 15. Full depth search
                     if (doFullDepthSearch)
                     {
                         // Full depth non-pv search using alpha as upperbound
-                        ss->reduction = Depth(0);
                         value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth);
 
                         // If we are above alpha then research at same depth but as PV
@@ -1467,12 +1481,13 @@ namespace {
     EvalInfo ei;
     StateInfo st;
     Move ttMove, move;
-    Value staticValue, bestValue, value, futilityBase, futilityValue;
+    Value staticValue, bestValue, value, futilityBase;
     bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
     const TTEntry* tte = NULL;
     int moveCount = 0;
     int ply = pos.ply();
     Value oldAlpha = alpha;
+    Value futilityValue = VALUE_INFINITE;
 
     TM.incrementNodeCounter(pos.thread());
     ss->init(ply);
@@ -1524,7 +1539,7 @@ namespace {
         return bestValue;
     }
 
-    if (bestValue > alpha)
+    if (PvNode && bestValue > alpha)
         alpha = bestValue;
 
     // If we are near beta then try to get a cutoff pushing checks a bit further
@@ -1560,6 +1575,11 @@ namespace {
           && !move_is_promotion(move)
           && !pos.move_is_passed_pawn_push(move))
       {
+          // Can only decrease from previous move because of
+          // MVV ordering so we don't need to recheck.
+          if (futilityValue < alpha)
+              continue;
+
           futilityValue =  futilityBase
                          + pos.endgame_value_of_piece_on(move_to(move))
                          + (move_is_ep(move) ? PawnValueEndgame : Value(0));