]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Make static value saved in TT independent from ply
[stockfish] / src / search.cpp
index 806a7fc4ce7596019cd3859dcad18412db5a2a0a..7bc90b143d10b85a94ff0a4cbf9f214e9d0b3525 100644 (file)
@@ -916,7 +916,7 @@ namespace {
         else
         {
             if (   newDepth >= 3*OnePly
-                && i >= MultiPV + LMRPVMoves - 2 // Remove -2 and decrease LMRPVMoves instead ?
+                && i >= MultiPV + LMRPVMoves
                 && !dangerous
                 && !moveIsCapture
                 && !move_is_promotion(move)
@@ -1540,10 +1540,10 @@ namespace {
         // Use the cached evaluation score if possible
         assert(ei.futilityMargin == Value(0));
 
-        staticValue = tte->value();
+        staticValue = tte->value() + ply;
     }
     else
-        staticValue = evaluate(pos, ei, threadID);
+        staticValue = evaluate(pos, ei, threadID) + ply;
 
     if (ply == PLY_MAX - 1)
         return evaluate(pos, ei, threadID);
@@ -1556,7 +1556,7 @@ namespace {
     {
         // Store the score to avoid a future costly evaluation() call
         if (!isCheck && !tte && ei.futilityMargin == 0)
-            TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_EVAL, Depth(-127*OnePly), MOVE_NONE);
+            TT.store(pos.get_key(), bestValue - ply, VALUE_TYPE_EVAL, Depth(-127*OnePly), MOVE_NONE);
 
         return bestValue;
     }
@@ -2185,7 +2185,7 @@ namespace {
     // Case 5: Discovered check, checking piece is the piece moved in m1
     if (   piece_is_slider(pos.piece_on(t1))
         && bit_is_set(squares_between(t1, pos.king_square(pos.side_to_move())), f2)
-        && !bit_is_set(squares_between(t2, pos.king_square(pos.side_to_move())), t2))
+        && !bit_is_set(squares_between(t1, pos.king_square(pos.side_to_move())), t2))
     {
         Bitboard occ = pos.occupied_squares();
         Color us = pos.side_to_move();