Refactor futility_margin

a small term to the futility calculation that depends on eval - beta.

Passed STC:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 203136 W: 52797 L: 52239 D: 98100
Ptnml(0-2): 549, 23827, 52255, 24391, 546
https://tests.stockfishchess.org/tests/view/680e84a43629b02d74b15e2e

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 100356 W: 25950 L: 25507 D: 48899
Ptnml(0-2): 35, 10683, 28302, 11120, 38
https://tests.stockfishchess.org/tests/view/680ebcb03629b02d74b16040

closes https://github.com/official-stockfish/Stockfish/pull/6009
closes https://github.com/official-stockfish/Stockfish/pull/6041

Bench: 1815939

Co-authored-by: Michael Chaly <Vizvezdenec@gmail.com>
Co-authored-by: xu-shawn <50402888+xu-shawn@users.noreply.github.com>
This commit is contained in:
FauziAkram
2025-04-28 16:46:30 +03:00
committed by Disservin
parent 0f905b4e88
commit ed6b8d179a

View File

@@ -70,23 +70,6 @@ namespace {
// so changing them or adding conditions that are similar requires // so changing them or adding conditions that are similar requires
// tests at these types of time controls. // tests at these types of time controls.
// Futility margin
Value futility_margin(Depth d,
bool noTtCutNode,
bool improving,
bool oppWorsening,
int statScore,
int correctionValue) {
Value futilityMult = 105 - 23 * noTtCutNode;
Value improvingDeduction = improving * futilityMult * 2;
Value worseningDeduction = oppWorsening * futilityMult / 3;
Value statScoreAddition = statScore / 335;
Value correctionAddition = correctionValue / 149902;
return futilityMult * d - improvingDeduction - worseningDeduction + statScoreAddition
+ correctionAddition;
}
constexpr int futility_move_count(bool improving, Depth depth) { constexpr int futility_move_count(bool improving, Depth depth) {
return (3 + depth * depth) / (2 - improving); return (3 + depth * depth) / (2 - improving);
} }
@@ -864,13 +847,23 @@ Value Search::Worker::search(
// Step 8. Futility pruning: child node // Step 8. Futility pruning: child node
// The depth condition is important for mate finding. // The depth condition is important for mate finding.
if (!ss->ttPv && depth < 14 {
&& eval auto futility_margin = [&](Depth d) {
- futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening, Value futilityMult = 105 - 23 * (cutNode && !ss->ttHit);
(ss - 1)->statScore, std::abs(correctionValue)) Value improvingDeduction = improving * futilityMult * 2;
>= beta Value worseningDeduction = opponentWorsening * futilityMult / 3;
&& eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta) && !is_win(eval))
return beta + (eval - beta) / 3; return futilityMult * d //
- improvingDeduction //
- worseningDeduction //
+ (ss - 1)->statScore / 335 //
+ std::abs(correctionValue) / 149902;
};
if (!ss->ttPv && depth < 14 && eval + (eval - beta) / 8 - futility_margin(depth) >= beta
&& eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta) && !is_win(eval))
return beta + (eval - beta) / 3;
}
// Step 9. Null move search with verification search // Step 9. Null move search with verification search
if (cutNode && (ss - 1)->currentMove != Move::null() && eval >= beta if (cutNode && (ss - 1)->currentMove != Move::null() && eval >= beta