]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
In qsearch update TT only if returning from stand pat
[stockfish] / src / search.cpp
index 8d6ddb8d33708c7443c6c8fb8b8a02d893c21b2a..c4446fc5d95bd4a6271fca322eb5b75ec8610d91 100644 (file)
@@ -1245,8 +1245,8 @@ namespace {
     {
         Value v = qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
         if (   (v < beta - RazorMargin - RazorMargin / 4)
-            || (depth < 3*OnePly && v < beta - RazorMargin)
-            || (depth < 2*OnePly && v < beta - RazorMargin / 2))
+            || (depth <= 2*OnePly && v < beta - RazorMargin)
+            || (depth <=   OnePly && v < beta - RazorMargin / 2))
             return v;
     }
 
@@ -1332,8 +1332,11 @@ namespace {
           && !move_is_castle(move)
           && !move_is_killer(move, ss[ply]))
       {
-          ss[ply].reduction = OnePly;
-          value = -search(pos, ss, -(beta-1), newDepth-OnePly, ply+1, true, threadID);
+          // LMR dynamic reduction
+          Depth R = (moveCount >= 2 * LMRNonPVMoves && depth > 7*OnePly ? 2*OnePly : OnePly);
+
+          ss[ply].reduction = R;
+          value = -search(pos, ss, -(beta-1), newDepth-R, ply+1, true, threadID);
       }
       else
         value = beta; // Just to trigger next condition
@@ -1447,7 +1450,11 @@ namespace {
     Value bestValue = staticValue;
 
     if (bestValue >= beta)
+    {
+        // Update transposition table before to leave
+        TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_EXACT);
         return bestValue;
+    }
 
     if (bestValue > alpha)
         alpha = bestValue;
@@ -1531,9 +1538,6 @@ namespace {
 
     assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
 
-    // Update transposition table
-    TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_EXACT);
-
     // Update killers only for good check moves
     Move m = ss[ply].currentMove;
     if (alpha >= beta && ok_to_history(pos, m)) // Only non capture moves are considered
@@ -2409,7 +2413,7 @@ namespace {
                      || (  !FailHigh && !fail_high_ply_1() && !Problem
                          && t > 6*(MaxSearchTime + ExtraSearchTime));
 
-    if (   (Iteration >= 2 && (!InfiniteSearch && overTime))
+    if (   (Iteration >= 3 && (!InfiniteSearch && overTime))
         || (ExactMaxTime && t >= ExactMaxTime)
         || (Iteration >= 3 && MaxNodes && nodes_searched() >= MaxNodes))
         AbortSearch = true;
@@ -2423,7 +2427,7 @@ namespace {
   void ponderhit() {
     int t = current_search_time();
     PonderSearch = false;
-    if(Iteration >= 2 &&
+    if(Iteration >= 3 &&
        (!InfiniteSearch && (StopOnPonderhit ||
                             t > AbsoluteMaxSearchTime ||
                             (RootMoveNumber == 1 &&