Skip to content

Commit

Permalink
VVLTC search tune
Browse files Browse the repository at this point in the history
Search parameters were tuned at 60+0.6 8-thread.
Link to the tuning attempt: https://tests.stockfishchess.org/tests/view/65b84e8dc865510db0276030

The most significant change is the triple extension parameter, from 200 to 78. This presumably improves scaling.
Additionally, the value < singularBeta - 2 condition for double extensions was removed.
This can simply be considered a parameter tweak from 2 to 0.

Passed VVLTC: https://tests.stockfishchess.org/tests/view/65baec69c865510db0278f19
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 26136 W: 6564 L: 6305 D: 13267
Ptnml(0-2): 2, 2413, 7977, 2676, 0

Passed VVLTC vs passed PR official-stockfish#5027: https://tests.stockfishchess.org/tests/view/65bc2adfc865510db027a561
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 52968 W: 13372 L: 13046 D: 26550
Ptnml(0-2): 4, 4944, 16265, 5264, 7

STC Elo estimate: https://tests.stockfishchess.org/tests/view/65be5514c865510db027cbc5

closes official-stockfish#5029

Bench: 1478189
  • Loading branch information
XInTheDark authored and vondele committed Feb 3, 2024
1 parent e815227 commit ededadc
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace {

// Futility margin
Value futility_margin(Depth d, bool noTtCutNode, bool improving) {
Value futilityMult = 114 - 47 * noTtCutNode;
Value futilityMult = 116 - 47 * noTtCutNode;
return (futilityMult * d - 3 * futilityMult / 2 * improving);
}

Expand All @@ -66,15 +66,15 @@ constexpr int futility_move_count(bool improving, Depth depth) {
// Add correctionHistory value to raw staticEval and guarantee evaluation does not hit the tablebase range
Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) {
auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index<Correction>(pos)];
v += cv * std::abs(cv) / 14095;
v += cv * std::abs(cv) / 12890;
return std::clamp(int(v), VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
}

// History and stats update bonus, based on depth
int stat_bonus(Depth d) { return std::min(265 * d - 349, 1112); }
int stat_bonus(Depth d) { return std::min(253 * d - 356, 1117); }

// History and stats update malus, based on depth
int stat_malus(Depth d) { return std::min(482 * d - 326, 1172); }
int stat_malus(Depth d) { return std::min(517 * d - 308, 1206); }

// Add a small random component to draw evaluations to avoid 3-fold blindness
Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); }
Expand Down Expand Up @@ -297,12 +297,12 @@ void Search::Worker::iterative_deepening() {

// Reset aspiration window starting size
Value avg = rootMoves[pvIdx].averageScore;
delta = Value(9) + int(avg) * avg / 13181;
delta = Value(9) + int(avg) * avg / 12480;
alpha = std::max(avg - delta, -VALUE_INFINITE);
beta = std::min(avg + delta, int(VALUE_INFINITE));

// Adjust optimism based on root move's averageScore (~4 Elo)
optimism[us] = 132 * avg / (std::abs(avg) + 98);
optimism[us] = 131 * avg / (std::abs(avg) + 95);
optimism[~us] = -optimism[us];

// Start with a small aspiration window and, in the case of a fail
Expand Down Expand Up @@ -726,7 +726,7 @@ Value Search::Worker::search(
// Use static evaluation difference to improve quiet move ordering (~9 Elo)
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
{
int bonus = std::clamp(-13 * int((ss - 1)->staticEval + ss->staticEval), -1680, 1406);
int bonus = std::clamp(-14 * int((ss - 1)->staticEval + ss->staticEval), -1661, 1495);
bonus = bonus > 0 ? 2 * bonus : bonus / 2;
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus;
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
Expand All @@ -747,7 +747,7 @@ Value Search::Worker::search(
// If eval is really low check with qsearch if it can exceed alpha, if it can't,
// return a fail low.
// Adjust razor margin according to cutoffCnt. (~1 Elo)
if (eval < alpha - 435 - (327 - 167 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
if (eval < alpha - 450 - (332 - 160 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
{
value = qsearch<NonPV>(pos, ss, alpha - 1, alpha);
if (value < alpha)
Expand All @@ -760,20 +760,20 @@ Value Search::Worker::search(
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving)
- (ss - 1)->statScore / 327
>= beta
&& eval >= beta && eval < 27734 // smaller than TB wins
&& eval >= beta && eval < 28702 // smaller than TB wins
&& (!ttMove || ttCapture))
return beta > VALUE_TB_LOSS_IN_MAX_PLY ? (eval + beta) / 2 : eval;

// Step 9. Null move search with verification search (~35 Elo)
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 17787
&& eval >= beta && eval >= ss->staticEval && ss->staticEval >= beta - 22 * depth + 313
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 17379
&& eval >= beta && eval >= ss->staticEval && ss->staticEval >= beta - 21 * depth + 329
&& !excludedMove && pos.non_pawn_material(us) && ss->ply >= thisThread->nmpMinPly
&& beta > VALUE_TB_LOSS_IN_MAX_PLY)
{
assert(eval - beta >= 0);

// Null move dynamic reduction based on depth and eval
Depth R = std::min(int(eval - beta) / 144, 6) + depth / 3 + 4;
Depth R = std::min(int(eval - beta) / 148, 6) + depth / 3 + 4;

ss->currentMove = Move::null();
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
Expand All @@ -787,7 +787,7 @@ Value Search::Worker::search(
// Do not return unproven mate or TB scores
if (nullValue >= beta && nullValue < VALUE_TB_WIN_IN_MAX_PLY)
{
if (thisThread->nmpMinPly || depth < 15)
if (thisThread->nmpMinPly || depth < 16)
return nullValue;

assert(!thisThread->nmpMinPly); // Recursive verification is not allowed
Expand Down Expand Up @@ -820,7 +820,7 @@ Value Search::Worker::search(
if (cutNode && depth >= 8 && !ttMove)
depth -= 2;

probCutBeta = beta + 173 - 73 * improving;
probCutBeta = beta + 182 - 68 * improving;

// Step 11. ProbCut (~10 Elo)
// If we have a good enough capture (or queen promotion) and a reduced search returns a value
Expand Down Expand Up @@ -880,7 +880,7 @@ Value Search::Worker::search(
moves_loop: // When in check, search starts here

// Step 12. A small Probcut idea, when we are in check (~4 Elo)
probCutBeta = beta + 427;
probCutBeta = beta + 446;
if (ss->inCheck && !PvNode && ttCapture && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 4 && ttValue >= probCutBeta
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
Expand Down Expand Up @@ -963,15 +963,15 @@ Value Search::Worker::search(
{
Piece capturedPiece = pos.piece_on(move.to_sq());
int futilityEval =
ss->staticEval + 277 + 298 * lmrDepth + PieceValue[capturedPiece]
ss->staticEval + 279 + 295 * lmrDepth + PieceValue[capturedPiece]
+ thisThread->captureHistory[movedPiece][move.to_sq()][type_of(capturedPiece)]
/ 7;
if (futilityEval < alpha)
continue;
}

// SEE based pruning for captures and checks (~11 Elo)
if (!pos.see_ge(move, -203 * depth))
if (!pos.see_ge(move, -204 * depth))
continue;
}
else
Expand All @@ -983,17 +983,17 @@ Value Search::Worker::search(
+ thisThread->pawnHistory[pawn_structure_index(pos)][movedPiece][move.to_sq()];

// Continuation history based pruning (~2 Elo)
if (lmrDepth < 6 && history < -4195 * depth)
if (lmrDepth < 6 && history < -4215 * depth)
continue;

history += 2 * thisThread->mainHistory[us][move.from_to()];

lmrDepth += history / 6992;
lmrDepth += history / 6658;

// Futility pruning: parent node (~13 Elo)
if (!ss->inCheck && lmrDepth < 15
&& ss->staticEval + (bestValue < ss->staticEval - 63 ? 137 : 64)
+ 111 * lmrDepth
&& ss->staticEval + (bestValue < ss->staticEval - 58 ? 139 : 55)
+ 121 * lmrDepth
<= alpha)
continue;

Expand All @@ -1020,11 +1020,11 @@ Value Search::Worker::search(
// so changing them requires tests at these types of time controls.
// Recursive singular search is avoided.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 31) + ss->ttPv
&& depth >= 4 - (thisThread->completedDepth > 29) + ss->ttPv
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3)
{
Value singularBeta = ttValue - (58 + 52 * (ss->ttPv && !PvNode)) * depth / 64;
Value singularBeta = ttValue - (62 + 52 * (ss->ttPv && !PvNode)) * depth / 64;
Depth singularDepth = newDepth / 2;

ss->excludedMove = move;
Expand All @@ -1037,10 +1037,10 @@ Value Search::Worker::search(
extension = 1;

// Avoid search explosion by limiting the number of double extensions
if (!PvNode && value < singularBeta - 2 && ss->doubleExtensions <= 15)
if (!PvNode && ss->doubleExtensions <= 16)
{
extension = 2 + (value < singularBeta - 200 && !ttCapture);
depth += depth < 15;
extension = 2 + (value < singularBeta - 78 && !ttCapture);
depth += depth < 16;
}
}

Expand Down Expand Up @@ -1077,14 +1077,14 @@ Value Search::Worker::search(

// Quiet ttMove extensions (~1 Elo)
else if (PvNode && move == ttMove && move == ss->killers[0]
&& (*contHist[0])[movedPiece][move.to_sq()] >= 4111)
&& (*contHist[0])[movedPiece][move.to_sq()] >= 4339)
extension = 1;

// Recapture extensions (~1 Elo)
else if (PvNode && move == ttMove && move.to_sq() == prevSq
&& thisThread->captureHistory[movedPiece][move.to_sq()]
[type_of(pos.piece_on(move.to_sq()))]
> 4484)
> 4356)
extension = 1;
}

Expand Down Expand Up @@ -1140,10 +1140,10 @@ Value Search::Worker::search(
ss->statScore = 2 * thisThread->mainHistory[us][move.from_to()]
+ (*contHist[0])[movedPiece][move.to_sq()]
+ (*contHist[1])[movedPiece][move.to_sq()]
+ (*contHist[3])[movedPiece][move.to_sq()] - 4119;
+ (*contHist[3])[movedPiece][move.to_sq()] - 4409;

// Decrease/increase reduction for moves with a good/bad history (~25 Elo)
r -= ss->statScore / 15373;
r -= ss->statScore / 14894;

// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
if (depth >= 2 && moveCount > 1 + rootNode)
Expand All @@ -1162,7 +1162,7 @@ Value Search::Worker::search(
{
// Adjust full-depth search based on LMR results - if the result
// was good enough search deeper, if it was bad enough search shallower.
const bool doDeeperSearch = value > (bestValue + 51 + 2 * newDepth); // (~1 Elo)
const bool doDeeperSearch = value > (bestValue + 49 + 2 * newDepth); // (~1 Elo)
const bool doShallowerSearch = value < bestValue + newDepth; // (~2 Elo)

newDepth += doDeeperSearch - doShallowerSearch;
Expand Down Expand Up @@ -1278,7 +1278,7 @@ Value Search::Worker::search(
else
{
// Reduce other moves if we have found at least one score improvement (~2 Elo)
if (depth > 2 && depth < 12 && beta < 13195 && value > -12346)
if (depth > 2 && depth < 13 && beta < 13710 && value > -12589)
depth -= 2;

assert(depth > 0);
Expand Down Expand Up @@ -1317,8 +1317,8 @@ Value Search::Worker::search(
// Bonus for prior countermove that caused the fail low
else if (!priorCapture && prevSq != SQ_NONE)
{
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -16797)
+ ((ss - 1)->moveCount > 10);
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -15401)
+ ((ss - 1)->moveCount > 11);
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
stat_bonus(depth) * bonus);
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()]
Expand Down Expand Up @@ -1476,7 +1476,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
if (bestValue > alpha)
alpha = bestValue;

futilityBase = ss->staticEval + 186;
futilityBase = ss->staticEval + 204;
}

const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory,
Expand Down Expand Up @@ -1556,7 +1556,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
continue;

// Do not search moves with bad enough SEE values (~5 Elo)
if (!pos.see_ge(move, -76))
if (!pos.see_ge(move, -75))
continue;
}

Expand Down Expand Up @@ -1711,7 +1711,7 @@ void update_all_stats(const Position& pos,

if (!pos.capture_stage(bestMove))
{
int bestMoveBonus = bestValue > beta + 177 ? quietMoveBonus // larger bonus
int bestMoveBonus = bestValue > beta + 167 ? quietMoveBonus // larger bonus
: stat_bonus(depth); // smaller bonus

// Increase stats for the best move in case it was a quiet move
Expand Down

0 comments on commit ededadc

Please sign in to comment.