@@ -480,7 +480,6 @@ void Search::Worker::iterative_deepening() {
480480 double fallingEval = (11.85 + 2.24 * (mainThread->bestPreviousAverageScore - bestValue)
481481 + 0.93 * (mainThread->iterValue [iterIdx] - bestValue))
482482 / 100.0 ;
483-
484483 fallingEval = std::clamp (fallingEval, 0.57 , 1.70 );
485484
486485 // If the bestMove is stable over several iterations, reduce time accordingly
@@ -717,7 +716,6 @@ Value Search::Worker::search(
717716 update_quiet_histories (pos, ss, *this , ttData.move ,
718717 std::min (132 * depth - 72 , 985 ));
719718
720-
721719 // Extra penalty for early quiet moves of the previous ply
722720 if (prevSq != SQ_NONE && (ss - 1 )->moveCount < 4 && !priorCapture)
723721 update_continuation_histories (ss - 1 , pos.piece_on (prevSq), prevSq, -2060 );
@@ -738,6 +736,7 @@ Value Search::Worker::search(
738736 // Check that the ttValue after the tt move would also trigger a cutoff
739737 if (!is_valid (ttDataNext.value ))
740738 return ttData.value ;
739+
741740 if ((ttData.value >= beta) == (-ttDataNext.value >= beta))
742741 return ttData.value ;
743742 }
@@ -858,6 +857,7 @@ Value Search::Worker::search(
858857 // Hindsight adjustment of reductions based on static evaluation difference.
859858 if (priorReduction >= 3 && !opponentWorsening)
860859 depth++;
860+
861861 if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1 )->staticEval > 169 )
862862 depth--;
863863
@@ -919,7 +919,6 @@ Value Search::Worker::search(
919919 }
920920 }
921921
922-
923922 improving |= ss->staticEval >= beta;
924923
925924 // Step 10. Internal iterative reductions
@@ -1187,7 +1186,6 @@ Value Search::Worker::search(
11871186 if (ss->ttPv )
11881187 r -= 2719 + PvNode * 983 + (ttData.value > alpha) * 922
11891188 + (ttData.depth >= depth) * (934 + cutNode * 1011 );
1190- // These reduction adjustments have no proven non-linear scaling
11911189
11921190 r += 714 ; // Base reduction offset to compensate for other tweaks
11931191 r -= moveCount * 73 ;
@@ -1220,7 +1218,6 @@ Value Search::Worker::search(
12201218 // Decrease/increase reduction for moves with a good/bad history
12211219 r -= ss->statScore * 850 / 8192 ;
12221220
1223-
12241221 // Step 17. Late moves reduction / extension (LMR)
12251222 if (depth >= 2 && moveCount > 1 )
12261223 {
@@ -1265,6 +1262,7 @@ Value Search::Worker::search(
12651262 value = -search<NonPV>(pos, ss + 1 , -(alpha + 1 ), -alpha,
12661263 newDepth - (r > 3957 ) - (r > 5654 && newDepth > 2 ), !cutNode);
12671264 }
1265+
12681266 // For PV nodes only, do a full PV search on the first move or after a fail high,
12691267 // otherwise let the parent node fail low with value <= alpha and try another move.
12701268 if (PvNode && (moveCount == 1 || value > alpha))
@@ -1445,7 +1443,6 @@ Value Search::Worker::search(
14451443 captureHistory[pos.piece_on (prevSq)][prevSq][type_of (capturedPiece)] << 1012 ;
14461444 }
14471445
1448-
14491446 if (PvNode)
14501447 bestValue = std::min (bestValue, maxValue);
14511448
@@ -1560,8 +1557,10 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
15601557 {
15611558 // Never assume anything about values stored in TT
15621559 unadjustedStaticEval = ttData.eval ;
1560+
15631561 if (!is_valid (unadjustedStaticEval))
15641562 unadjustedStaticEval = evaluate (pos);
1563+
15651564 ss->staticEval = bestValue =
15661565 to_corrected_static_eval (unadjustedStaticEval, correctionValue);
15671566
@@ -1573,8 +1572,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
15731572 else
15741573 {
15751574 unadjustedStaticEval = evaluate (pos);
1576-
1577- ss->staticEval = bestValue =
1575+ ss->staticEval = bestValue =
15781576 to_corrected_static_eval (unadjustedStaticEval, correctionValue);
15791577 }
15801578
@@ -1583,6 +1581,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
15831581 {
15841582 if (!is_decisive (bestValue))
15851583 bestValue = (bestValue + beta) / 2 ;
1584+
15861585 if (!ss->ttHit )
15871586 ttWriter.write (posKey, value_to_tt (bestValue, ss->ply ), false , BOUND_LOWER,
15881587 DEPTH_UNSEARCHED, Move::none (), unadjustedStaticEval,
@@ -1596,7 +1595,6 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
15961595 futilityBase = ss->staticEval + 351 ;
15971596 }
15981597
1599-
16001598 const PieceToHistory* contHist[] = {(ss - 1 )->continuationHistory };
16011599
16021600 Square prevSq = ((ss - 1 )->currentMove ).is_ok () ? ((ss - 1 )->currentMove ).to_sq () : SQ_NONE;
@@ -1699,7 +1697,6 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
16991697 if (!is_decisive (bestValue) && bestValue > beta)
17001698 bestValue = (bestValue + beta) / 2 ;
17011699
1702-
17031700 Color us = pos.side_to_move ();
17041701 if (!ss->inCheck && !moveCount && !pos.non_pawn_material (us)
17051702 && type_of (pos.captured_piece ()) >= ROOK)
@@ -1731,7 +1728,6 @@ Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) const {
17311728 return reductionScale - delta * 608 / rootDelta + !i * reductionScale * 238 / 512 + 1182 ;
17321729}
17331730
1734-
17351731// elapsed() returns the time elapsed since the search started. If the
17361732// 'nodestime' option is enabled, it will return the count of nodes searched
17371733// instead. This function is called to check whether the search should be
@@ -1869,6 +1865,7 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
18691865 // Only update the first 2 continuation histories if we are in check
18701866 if (ss->inCheck && i > 2 )
18711867 break ;
1868+
18721869 if (((ss - i)->currentMove ).is_ok ())
18731870 (*(ss - i)->continuationHistory )[pc][to] << (bonus * weight / 1024 ) + 88 * (i < 2 );
18741871 }
@@ -1925,7 +1922,6 @@ Move Skill::pick_best(const RootMoves& rootMoves, size_t multiPV) {
19251922 return best;
19261923}
19271924
1928-
19291925// Used to print debug info and, more importantly, to detect
19301926// when we are out of available time and thus stop the search.
19311927void SearchManager::check_time (Search::Worker& worker) {
0 commit comments