Merge commit '5297ba0a1a1aa0a15332e0d64ce6b32952342cac' into cluster

This commit is contained in:
Steinar H. Gunderson
2025-12-25 20:22:26 +01:00
+50 -48
View File
@@ -750,6 +750,56 @@ Value Search::Worker::search(
// At this point, if excluded, skip straight to step 6, static eval. However,
// to save indentation, we list the condition in all code between here and there.
// Step 6. Static evaluation of the position
Value unadjustedStaticEval = VALUE_NONE;
const auto correctionValue = correction_value(*this, pos, ss);
if (ss->inCheck)
{
// Skip early pruning when in check
ss->staticEval = eval = (ss - 2)->staticEval;
improving = false;
}
else if (excludedMove)
unadjustedStaticEval = eval = ss->staticEval;
else if (ss->ttHit)
{
// Never assume anything about values stored in TT
unadjustedStaticEval = ttData.eval;
if (!is_valid(unadjustedStaticEval))
unadjustedStaticEval = evaluate(pos);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, correctionValue);
// ttValue can be used as a better position evaluation
if (is_valid(ttData.value)
&& (ttData.bound & (ttData.value > eval ? BOUND_LOWER : BOUND_UPPER)))
eval = ttData.value;
}
else
{
unadjustedStaticEval = evaluate(pos);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, correctionValue);
// Static evaluation is saved as it was before adjustment by correction history
Distributed::save(tt, threads, this, ttWriter, posKey, VALUE_NONE, ss->ttPv, BOUND_NONE,
DEPTH_UNSEARCHED, Move::none(), unadjustedStaticEval, tt.generation());
}
// Set up the improving flag, which is true if current static evaluation is
// bigger than the previous static evaluation at our turn (if we were in
// check at our previous move we go back until we weren't in check) and is
// false otherwise. The improving flag is used in various pruning heuristics.
// Similarly, opponentWorsening is true if our static evaluation is better
// for us than at the last ply.
improving = ss->staticEval > (ss - 2)->staticEval;
opponentWorsening = ss->staticEval > -(ss - 1)->staticEval;
// Hindsight adjustment of reductions based on static evaluation difference.
if (priorReduction >= 3 && !opponentWorsening)
depth++;
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 173)
depth--;
// At non-PV nodes we check for an early TT cutoff
if (!PvNode && !excludedMove && ttData.depth > depth - (ttData.value <= beta)
&& is_valid(ttData.value) // Can happen when !ttHit or when access race in probe()
@@ -847,41 +897,8 @@ Value Search::Worker::search(
}
}
// Step 6. Static evaluation of the position
Value unadjustedStaticEval = VALUE_NONE;
const auto correctionValue = correction_value(*this, pos, ss);
if (ss->inCheck)
{
// Skip early pruning when in check
ss->staticEval = eval = (ss - 2)->staticEval;
improving = false;
goto moves_loop;
}
else if (excludedMove)
unadjustedStaticEval = eval = ss->staticEval;
else if (ss->ttHit)
{
// Never assume anything about values stored in TT
unadjustedStaticEval = ttData.eval;
if (!is_valid(unadjustedStaticEval))
unadjustedStaticEval = evaluate(pos);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, correctionValue);
// ttValue can be used as a better position evaluation
if (is_valid(ttData.value)
&& (ttData.bound & (ttData.value > eval ? BOUND_LOWER : BOUND_UPPER)))
eval = ttData.value;
}
else
{
unadjustedStaticEval = evaluate(pos);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, correctionValue);
// Static evaluation is saved as it was before adjustment by correction history
Distributed::save(tt, threads, this, ttWriter, posKey, VALUE_NONE, ss->ttPv, BOUND_NONE,
DEPTH_UNSEARCHED, Move::none(), unadjustedStaticEval, tt.generation());
}
// Use static evaluation difference to improve quiet move ordering
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
@@ -893,21 +910,6 @@ Value Search::Worker::search(
pawnHistory[pawn_history_index(pos)][pos.piece_on(prevSq)][prevSq] << evalDiff * 13;
}
// Set up the improving flag, which is true if current static evaluation is
// bigger than the previous static evaluation at our turn (if we were in
// check at our previous move we go back until we weren't in check) and is
// false otherwise. The improving flag is used in various pruning heuristics.
// Similarly, opponentWorsening is true if our static evaluation is better
// for us than at the last ply.
improving = ss->staticEval > (ss - 2)->staticEval;
opponentWorsening = ss->staticEval > -(ss - 1)->staticEval;
// Hindsight adjustment of reductions based on static evaluation difference.
if (priorReduction >= 3 && !opponentWorsening)
depth++;
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 169)
depth--;
// Step 7. Razoring
// If eval is really low, skip search entirely and return the qsearch value.