]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
MaxGain based futility pruning for captures
[stockfish] / src / search.cpp
index 6173a9a4b410d98efb1c9ca3f7fc5646fa8db3b5..f259ab707fe7983a271bdd6b05093490d6fe404a 100644 (file)
@@ -1556,6 +1556,28 @@ namespace {
       // Update current move
       movesSearched[moveCount++] = ss[ply].currentMove = move;
 
       // Update current move
       movesSearched[moveCount++] = ss[ply].currentMove = move;
 
+      // Futility pruning for captures
+      Color them = opposite_color(pos.side_to_move());
+
+      if (    useFutilityPruning
+          && !dangerous
+          && pos.move_is_capture(move)
+          && !pos.move_is_check(move, ci)
+          && !move_is_promotion(move)
+          && move != ttMove
+          && !move_is_ep(move)
+          && (pos.type_of_piece_on(move_to(move)) != PAWN || !pos.pawn_is_passed(them, move_to(move)))) // Do not prune passed pawn captures
+      {
+          int preFutilityValueMargin = 0;
+
+          if (newDepth >= OnePly)
+              preFutilityValueMargin = 112 * bitScanReverse32(int(newDepth) * int(newDepth) / 2);
+
+          if (ss[ply].eval + pos.endgame_value_of_piece_on(move_to(move)) + preFutilityValueMargin + ei.futilityMargin + 90 < beta)
+              continue;
+      }
+
+
       // Futility pruning
       if (    useFutilityPruning
           && !dangerous
       // Futility pruning
       if (    useFutilityPruning
           && !dangerous