]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Retire UseQSearchFutilityPruning and UseFutilityPruning
[stockfish] / src / search.cpp
index d8c0c7dd3f4ad89db231456a5fe3c82c3324fc35..66bdb9b8b266b1c6c344cf3a92535037d5aa8f01 100644 (file)
@@ -128,14 +128,7 @@ namespace {
   };
 
 
   };
 
 
-  /// Constants and variables initialized from UCI options
-
-  // Minimum number of full depth (i.e. non-reduced) moves at PV and non-PV
-  // nodes
-  int LMRPVMoves, LMRNonPVMoves;
-
-  // Depth limit for use of dynamic threat detection
-  Depth ThreatDepth;
+  /// Constants
 
   // Depth limit for selective search
   const Depth SelectiveDepth = 7*OnePly;
 
   // Depth limit for selective search
   const Depth SelectiveDepth = 7*OnePly;
@@ -174,25 +167,32 @@ namespace {
   const bool PruneDefendingMoves = false;
   const bool PruneBlockingMoves = false;
 
   const bool PruneDefendingMoves = false;
   const bool PruneBlockingMoves = false;
 
-  // Use futility pruning?
-  bool UseQSearchFutilityPruning, UseFutilityPruning;
-
   // Margins for futility pruning in the quiescence search, and at frontier
   // and near frontier nodes
   const Value FutilityMarginQS = Value(0x80);
 
   // Margins for futility pruning in the quiescence search, and at frontier
   // and near frontier nodes
   const Value FutilityMarginQS = Value(0x80);
 
-   // Remaining depth:                  1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
-   const Value FutilityMargins[12] = { Value(0x100), Value(0x120), Value(0x200), Value(0x220), Value(0x250), Value(0x270),
+  // Remaining depth:                  1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
+  const Value FutilityMargins[12] = { Value(0x100), Value(0x120), Value(0x200), Value(0x220), Value(0x250), Value(0x270),
   //                                   4 ply         4.5 ply       5 ply         5.5 ply       6 ply         6.5 ply
                                       Value(0x2A0), Value(0x2C0), Value(0x340), Value(0x360), Value(0x3A0), Value(0x3C0) };
   //                                   4 ply         4.5 ply       5 ply         5.5 ply       6 ply         6.5 ply
                                       Value(0x2A0), Value(0x2C0), Value(0x340), Value(0x360), Value(0x3A0), Value(0x3C0) };
-   // Razoring
-   const Depth RazorDepth = 4*OnePly;
+  // Razoring
+  const Depth RazorDepth = 4*OnePly;
 
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
   const Value RazorMargins[6]     = { Value(0x180), Value(0x300), Value(0x300), Value(0x3C0), Value(0x3C0), Value(0x3C0) };
 
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
 
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
   const Value RazorMargins[6]     = { Value(0x180), Value(0x300), Value(0x300), Value(0x3C0), Value(0x3C0), Value(0x3C0) };
 
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
-   const Value RazorApprMargins[6] = { Value(0x520), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
+  const Value RazorApprMargins[6] = { Value(0x520), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
+
+
+  /// Variables initialized from UCI options
+
+  // Minimum number of full depth (i.e. non-reduced) moves at PV and non-PV
+  // nodes
+  int LMRPVMoves, LMRNonPVMoves;
+
+  // Depth limit for use of dynamic threat detection
+  Depth ThreatDepth;
 
   // Last seconds noise filtering (LSN)
   bool UseLSNFiltering;
 
   // Last seconds noise filtering (LSN)
   bool UseLSNFiltering;
@@ -207,15 +207,15 @@ namespace {
   // Search depth at iteration 1
   const Depth InitialDepth = OnePly /*+ OnePly/2*/;
 
   // Search depth at iteration 1
   const Depth InitialDepth = OnePly /*+ OnePly/2*/;
 
-  // Node counters
+  // Node counters, used only by thread[0]
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
   // Iteration counters
   int Iteration;
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
   // Iteration counters
   int Iteration;
-  BetaCounterType BetaCounter;
+  BetaCounterType BetaCounter; // does not have internal data
 
 
-  // Scores and number of times the best move changed for each iteration:
+  // Scores and number of times the best move changed for each iteration
   IterationInfoType IterationInfo[PLY_MAX_PLUS_2];
   int BestMoveChangesByIteration[PLY_MAX_PLUS_2];
 
   IterationInfoType IterationInfo[PLY_MAX_PLUS_2];
   int BestMoveChangesByIteration[PLY_MAX_PLUS_2];
 
@@ -432,9 +432,6 @@ bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
   if (UseLogFile)
       LogFile.open(get_option_value_string("Search Log Filename").c_str(), std::ios::out | std::ios::app);
 
   if (UseLogFile)
       LogFile.open(get_option_value_string("Search Log Filename").c_str(), std::ios::out | std::ios::app);
 
-  UseQSearchFutilityPruning = get_option_value_bool("Futility Pruning (Quiescence Search)");
-  UseFutilityPruning = get_option_value_bool("Futility Pruning (Main Search)");
-
   UseLSNFiltering = get_option_value_bool("LSN filtering");
   LSNTime = get_option_value_int("LSN Time Margin (sec)") * 1000;
   LSNValue = value_from_centipawns(get_option_value_int("LSN Value Margin"));
   UseLSNFiltering = get_option_value_bool("LSN filtering");
   LSNTime = get_option_value_int("LSN Time Margin (sec)") * 1000;
   LSNValue = value_from_centipawns(get_option_value_int("LSN Value Margin"));
@@ -1324,8 +1321,7 @@ namespace {
     Value value, bestValue = -VALUE_INFINITE;
     Bitboard dcCandidates = mp.discovered_check_candidates();
     Value futilityValue = VALUE_NONE;
     Value value, bestValue = -VALUE_INFINITE;
     Bitboard dcCandidates = mp.discovered_check_candidates();
     Value futilityValue = VALUE_NONE;
-    bool useFutilityPruning =   UseFutilityPruning
-                             && depth < SelectiveDepth
+    bool useFutilityPruning =   depth < SelectiveDepth
                              && !isCheck;
 
     // Loop through all legal moves until no moves remain or a beta cutoff
                              && !isCheck;
 
     // Loop through all legal moves until no moves remain or a beta cutoff
@@ -1556,8 +1552,7 @@ namespace {
       ss[ply].currentMove = move;
 
       // Futility pruning
       ss[ply].currentMove = move;
 
       // Futility pruning
-      if (    UseQSearchFutilityPruning
-          &&  enoughMaterial
+      if (   enoughMaterial
           && !isCheck
           && !pvNode
           && !move_promotion(move)
           && !isCheck
           && !pvNode
           && !move_promotion(move)
@@ -1651,8 +1646,7 @@ namespace {
     Value value;
     Move move;
     bool isCheck = pos.is_check();
     Value value;
     Move move;
     bool isCheck = pos.is_check();
-    bool useFutilityPruning =    UseFutilityPruning
-                              && sp->depth < SelectiveDepth
+    bool useFutilityPruning =     sp->depth < SelectiveDepth
                               && !isCheck;
 
     while (    sp->bestValue < sp->beta
                               && !isCheck;
 
     while (    sp->bestValue < sp->beta