]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Add mild extension in low depths
[stockfish] / src / search.cpp
index d0ddbd55045639a4e0a0ea87b8d46753c015bb83..ab34a8451cceda529f7996faf4df0500d6715f0c 100644 (file)
@@ -1135,7 +1135,7 @@ namespace {
       moveIsCheck = pos.move_is_check(move, ci);
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
       moveIsCheck = pos.move_is_check(move, ci);
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
-      movesSearched[moveCount++] = ss[ply].currentMove = move;
+      movesSearched[moveCount++] = move;
 
       // Decide the new search depth
       ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous);
 
       // Decide the new search depth
       ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous);
@@ -1143,7 +1143,7 @@ namespace {
       // Only move extension
       if (   moveCount == 1
           && ext < OnePly
       // Only move extension
       if (   moveCount == 1
           && ext < OnePly
-          && depth >= 8 * OnePly
+          && depth >= 4 * OnePly
           && tte
           && (tte->type() & VALUE_TYPE_LOWER)
           && tte->move() != MOVE_NONE
           && tte
           && (tte->type() & VALUE_TYPE_LOWER)
           && tte->move() != MOVE_NONE
@@ -1152,14 +1152,17 @@ namespace {
           Value ttValue = value_from_tt(tte->value(), ply);
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
           Value ttValue = value_from_tt(tte->value(), ply);
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
-              Value excValue = search(pos, ss, ttValue - OnlyMoveMargin, depth / 2, ply, false, threadID, tte->move());
+              Value excValue = search(pos, ss, ttValue - OnlyMoveMargin, Max(Min(depth / 2,  depth - 4 * OnePly), OnePly), ply, false, threadID, tte->move());
               if (excValue < ttValue - OnlyMoveMargin)
               if (excValue < ttValue - OnlyMoveMargin)
-                  ext = OnePly;
+                  ext = (depth >= 8 * OnePly)? OnePly : ext + OnePly / 2;
           }
       }
 
       newDepth = depth - OnePly + ext;
 
           }
       }
 
       newDepth = depth - OnePly + ext;
 
+      // Update current move
+      ss[ply].currentMove = move;
+
       // Make and search the move
       pos.do_move(move, st, ci, moveIsCheck);
 
       // Make and search the move
       pos.do_move(move, st, ci, moveIsCheck);
 
@@ -1434,7 +1437,7 @@ namespace {
       moveIsCheck = pos.move_is_check(move, ci);
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
       moveIsCheck = pos.move_is_check(move, ci);
       captureOrPromotion = pos.move_is_capture_or_promotion(move);
 
-      movesSearched[moveCount++] = ss[ply].currentMove = move;
+      movesSearched[moveCount++] = move;
 
       // Decide the new search depth
       ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous);
 
       // Decide the new search depth
       ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, singleReply, mateThreat, &dangerous);
@@ -1443,7 +1446,7 @@ namespace {
       if (   forbiddenMove == MOVE_NONE
           && moveCount == 1
           && ext < OnePly
       if (   forbiddenMove == MOVE_NONE
           && moveCount == 1
           && ext < OnePly
-          && depth >= 8 * OnePly
+          && depth >= 4 * OnePly
           && tte
           && (tte->type() & VALUE_TYPE_LOWER)
           && tte->move() != MOVE_NONE
           && tte
           && (tte->type() & VALUE_TYPE_LOWER)
           && tte->move() != MOVE_NONE
@@ -1452,14 +1455,17 @@ namespace {
           Value ttValue = value_from_tt(tte->value(), ply);
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
           Value ttValue = value_from_tt(tte->value(), ply);
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
-              Value excValue = search(pos, ss, ttValue - OnlyMoveMargin, depth / 2, ply, false, threadID, tte->move());
+              Value excValue = search(pos, ss, ttValue - OnlyMoveMargin, Max(Min(depth / 2,  depth - 4 * OnePly), OnePly), ply, false, threadID, tte->move());
               if (excValue < ttValue - OnlyMoveMargin)
               if (excValue < ttValue - OnlyMoveMargin)
-                  ext = OnePly;
+                  ext = (depth >= 8 * OnePly)? OnePly : ext + OnePly / 2;
           }
       }
 
       newDepth = depth - OnePly + ext;
 
           }
       }
 
       newDepth = depth - OnePly + ext;
 
+      // Update current move
+      ss[ply].currentMove = move;
+
       // Futility pruning
       if (    useFutilityPruning
           && !dangerous
       // Futility pruning
       if (    useFutilityPruning
           && !dangerous