]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Remove some useless casts
[stockfish] / src / search.cpp
index 2ae1c368c4e76b62c17f8e275b27ed32a5f5f1d8..d0929d5dfb3f34a019979a2825c8014d56b6a6a5 100644 (file)
@@ -45,6 +45,7 @@ namespace Search {
   Color RootColor;
   Time::point SearchTime;
   StateStackPtr SetupStates;
+  Value Contempt[2]; // [bestValue > VALUE_DRAW]
 }
 
 using std::string;
@@ -60,13 +61,13 @@ namespace {
   enum NodeType { Root, PV, NonPV, SplitPointRoot, SplitPointPV, SplitPointNonPV };
 
   // Dynamic razoring margin based on depth
-  inline Value razor_margin(Depth d) { return Value(512 + 16 * int(d)); }
+  inline Value razor_margin(Depth d) { return Value(512 + 16 * d); }
 
   // Futility lookup tables (initialized at startup) and their access functions
   int FutilityMoveCounts[2][32]; // [improving][depth]
 
   inline Value futility_margin(Depth d) {
-    return Value(100 * int(d));
+    return Value(100 * d);
   }
 
   // Reduction lookup tables (initialized at startup) and their access function
@@ -145,8 +146,8 @@ void Search::init() {
   // Init futility move count array
   for (d = 0; d < 32; ++d)
   {
-      FutilityMoveCounts[0][d] = int(2.4 + 0.222 * pow(d + 0.00, 1.8));
-      FutilityMoveCounts[1][d] = int(3.0 + 0.300 * pow(d + 0.98, 1.8));
+      FutilityMoveCounts[0][d] = 2.4 + 0.222 * pow(d + 0.00, 1.8);
+      FutilityMoveCounts[1][d] = 3.0 + 0.300 * pow(d + 0.98, 1.8);
   }
 }
 
@@ -185,9 +186,9 @@ void Search::think() {
   RootColor = RootPos.side_to_move();
   TimeMgr.init(Limits, RootPos.game_ply(), RootColor);
 
-  int cf = Options["Contempt Factor"] * PawnValueEg / 100; // From centipawns
-  DrawValue[ RootColor] = VALUE_DRAW - Value(cf);
-  DrawValue[~RootColor] = VALUE_DRAW + Value(cf);
+  DrawValue[0] = DrawValue[1] = VALUE_DRAW;
+  Contempt[0] =  Options["Contempt Factor"] * PawnValueEg / 100; // From centipawns
+  Contempt[1] = (Options["Contempt Factor"] + 12) * PawnValueEg / 100;
 
   if (RootMoves.empty())
   {
@@ -339,6 +340,9 @@ namespace {
             {
                 bestValue = search<Root>(pos, ss, alpha, beta, depth * ONE_PLY, false);
 
+                DrawValue[ RootColor] = VALUE_DRAW - Contempt[bestValue > VALUE_DRAW];
+                DrawValue[~RootColor] = VALUE_DRAW + Contempt[bestValue > VALUE_DRAW];
+
                 // Bring the best move to the front. It is critical that sorting
                 // is done with a stable algorithm because all the values but the
                 // first and eventually the new best one are set to -VALUE_INFINITE
@@ -679,7 +683,7 @@ namespace {
     // Step 10. Internal iterative deepening (skipped when in check)
     if (    depth >= (PvNode ? 5 * ONE_PLY : 8 * ONE_PLY)
         && !ttMove
-        && (PvNode || ss->staticEval + Value(256) >= beta))
+        && (PvNode || ss->staticEval + 256 >= beta))
     {
         Depth d = depth - 2 * ONE_PLY - (PvNode ? DEPTH_ZERO : depth / 4);
 
@@ -819,7 +823,7 @@ moves_loop: // When in check and at SpNode search starts from here
           if (predictedDepth < 7 * ONE_PLY)
           {
               futilityValue = ss->staticEval + futility_margin(predictedDepth)
-                            + Value(128) + Gains[pos.moved_piece(move)][to_sq(move)];
+                            + 128 + Gains[pos.moved_piece(move)][to_sq(move)];
 
               if (futilityValue <= alpha)
               {
@@ -1124,7 +1128,7 @@ moves_loop: // When in check and at SpNode search starts from here
         if (PvNode && bestValue > alpha)
             alpha = bestValue;
 
-        futilityBase = bestValue + Value(128);
+        futilityBase = bestValue + 128;
     }
 
     // Initialize a MovePicker object for the current position, and prepare