]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Prune dangerous moves at low depth
[stockfish] / src / search.cpp
index 7fafe933d5fda20eb2f9d60bb678c0cc796e4d81..9779aeab84e79680e99facd1f79c9904dc93a98f 100644 (file)
@@ -622,7 +622,7 @@ namespace {
     // search to overwrite a previous full search TT value, so we use a different
     // position key in case of an excluded move.
     excludedMove = ss->excludedMove;
-    posKey = excludedMove ? pos.exclusion_key() : pos.key();
+    posKey = pos.key() ^ Key(excludedMove);
     tte = TT.probe(posKey, ttHit);
     ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
     ttMove =  rootNode ? thisThread->rootMoves[thisThread->PVIdx].pv[0]
@@ -650,7 +650,7 @@ namespace {
             }
 
             // Extra penalty for a quiet TT move in previous ply when it gets refuted
-            if ((ss-1)->moveCount == 1 && !pos.captured_piece_type())
+            if ((ss-1)->moveCount == 1 && !pos.captured_piece())
             {
                 Value penalty = Value(d * d + 4 * d + 1);
                 Square prevSq = to_sq((ss-1)->currentMove);
@@ -956,6 +956,16 @@ moves_loop: // When in check search starts from here
                   continue;
           }
       }
+      else if (    depth < 3 * ONE_PLY
+               && !inCheck
+               &&  bestValue > VALUE_MATED_IN_MAX_PLY
+               && !rootNode
+               && (  captureOrPromotion
+                   || givesCheck
+                   || pos.advanced_pawn_push(move))
+               && pos.see_sign(move) < VALUE_ZERO
+               )
+          continue;
 
       // Speculative prefetch as early as possible
       prefetch(TT.first_entry(pos.key_after(move)));
@@ -1138,7 +1148,7 @@ moves_loop: // When in check search starts from here
         }
 
         // Extra penalty for a quiet TT move in previous ply when it gets refuted
-        if ((ss-1)->moveCount == 1 && !pos.captured_piece_type())
+        if ((ss-1)->moveCount == 1 && !pos.captured_piece())
         {
             Value penalty = Value(d * d + 4 * d + 1);
             Square prevSq = to_sq((ss-1)->currentMove);
@@ -1147,7 +1157,7 @@ moves_loop: // When in check search starts from here
     }
     // Bonus for prior countermove that caused the fail low
     else if (    depth >= 3 * ONE_PLY
-             && !pos.captured_piece_type()
+             && !pos.captured_piece()
              && is_ok((ss-1)->currentMove))
     {
         int d = depth / ONE_PLY;
@@ -1641,7 +1651,7 @@ void Tablebases::filter_root_moves(Position& pos, Search::RootMoves& rootMoves)
         RootInTB = root_probe_wdl(pos, rootMoves, TB::Score);
 
         // Only probe during search if winning
-        if (TB::Score <= VALUE_DRAW)
+        if (RootInTB && TB::Score <= VALUE_DRAW)
             Cardinality = 0;
     }