Skip to content

Commit 070e564

Browse files
XInTheDarkDisservin
authored andcommitted
VVLTC search tune
This patch is the result of two tuning stages: 1. ~32k games at 60+0.6 th8: https://tests.stockfishchess.org/tests/view/662d9dea6115ff6764c7f817 2. ~193k games at 80+0.8 th6, based on PR #5211: https://tests.stockfishchess.org/tests/view/663587e273559a8aa857ca00. Based on extensive VVLTC tuning and testing both before and after #5211, it is observed that introduction of new extensions positively affected the search tune results. Passed VVLTC 70+0.7 th7 1st sprt: https://tests.stockfishchess.org/tests/view/6636c6f04b68b70d85801409 LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 18566 W: 4864 L: 4620 D: 9082 Ptnml(0-2): 0, 1608, 5827, 1844, 4 Passed VVLTC 70+0.7 th7 2nd sprt: https://tests.stockfishchess.org/tests/view/6636d4b84b68b70d85802ab7 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 43142 W: 11141 L: 10838 D: 21163 Ptnml(0-2): 4, 3915, 13427, 4224, 1 Passed VVLTC 70+0.7 3rd sprt: https://tests.stockfishchess.org/tests/view/66376b4f9819650825aa230b LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 40322 W: 10374 L: 10076 D: 19872 Ptnml(0-2): 1, 3660, 12544, 3952, 4 The first two sprts were run against passed #5211. The third sprt was run against latest master. closes #5216 Bench: 2180675
1 parent 61f12a4 commit 070e564

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/search.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ static constexpr double EvalLevel[10] = {0.981, 0.956, 0.895, 0.949, 0.913,
5959

6060
// Futility margin
6161
Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorsening) {
62-
Value futilityMult = 118 - 45 * noTtCutNode;
63-
Value improvingDeduction = 52 * improving * futilityMult / 32;
64-
Value worseningDeduction = (316 + 48 * improving) * oppWorsening * futilityMult / 1024;
62+
Value futilityMult = 126 - 46 * noTtCutNode;
63+
Value improvingDeduction = 58 * improving * futilityMult / 32;
64+
Value worseningDeduction = (323 + 52 * improving) * oppWorsening * futilityMult / 1024;
6565

6666
return futilityMult * d - improvingDeduction - worseningDeduction;
6767
}
@@ -73,15 +73,15 @@ constexpr int futility_move_count(bool improving, Depth depth) {
7373
// Add correctionHistory value to raw staticEval and guarantee evaluation does not hit the tablebase range
7474
Value to_corrected_static_eval(Value v, const Worker& w, const Position& pos) {
7575
auto cv = w.correctionHistory[pos.side_to_move()][pawn_structure_index<Correction>(pos)];
76-
v += cv * std::abs(cv) / 9260;
76+
v += cv * std::abs(cv) / 7350;
7777
return std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
7878
}
7979

8080
// History and stats update bonus, based on depth
81-
int stat_bonus(Depth d) { return std::clamp(214 * d - 318, 16, 1304); }
81+
int stat_bonus(Depth d) { return std::clamp(208 * d - 297, 16, 1406); }
8282

8383
// History and stats update malus, based on depth
84-
int stat_malus(Depth d) { return (d < 4 ? 572 * d - 284 : 1355); }
84+
int stat_malus(Depth d) { return (d < 4 ? 520 * d - 312 : 1479); }
8585

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

311311
// Reset aspiration window starting size
312312
Value avg = rootMoves[pvIdx].averageScore;
313-
delta = 10 + avg * avg / 11480;
313+
delta = 10 + avg * avg / 9530;
314314
alpha = std::max(avg - delta, -VALUE_INFINITE);
315315
beta = std::min(avg + delta, VALUE_INFINITE);
316316

317317
// Adjust optimism based on root move's averageScore (~4 Elo)
318-
optimism[us] = 122 * avg / (std::abs(avg) + 92);
318+
optimism[us] = 119 * avg / (std::abs(avg) + 88);
319319
optimism[~us] = -optimism[us];
320320

321321
// Start with a small aspiration window and, in the case of a fail
@@ -502,10 +502,10 @@ void Search::Worker::clear() {
502502
for (StatsType c : {NoCaptures, Captures})
503503
for (auto& to : continuationHistory[inCheck][c])
504504
for (auto& h : to)
505-
h->fill(-65);
505+
h->fill(-60);
506506

507507
for (size_t i = 1; i < reductions.size(); ++i)
508-
reductions[i] = int((20.14 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
508+
reductions[i] = int((18.93 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
509509

510510
refreshTable.clear(networks);
511511
}
@@ -738,7 +738,7 @@ Value Search::Worker::search(
738738
// Use static evaluation difference to improve quiet move ordering (~9 Elo)
739739
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
740740
{
741-
int bonus = std::clamp(-14 * int((ss - 1)->staticEval + ss->staticEval), -1644, 1384);
741+
int bonus = std::clamp(-13 * int((ss - 1)->staticEval + ss->staticEval), -1796, 1526);
742742
bonus = bonus > 0 ? 2 * bonus : bonus / 2;
743743
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus;
744744
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
@@ -761,7 +761,7 @@ Value Search::Worker::search(
761761
// If eval is really low check with qsearch if it can exceed alpha, if it can't,
762762
// return a fail low.
763763
// Adjust razor margin according to cutoffCnt. (~1 Elo)
764-
if (eval < alpha - 471 - (275 - 148 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
764+
if (eval < alpha - 433 - (302 - 141 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
765765
{
766766
value = qsearch<NonPV>(pos, ss, alpha - 1, alpha);
767767
if (value < alpha)
@@ -770,23 +770,23 @@ Value Search::Worker::search(
770770

771771
// Step 8. Futility pruning: child node (~40 Elo)
772772
// The depth condition is important for mate finding.
773-
if (!ss->ttPv && depth < 12
773+
if (!ss->ttPv && depth < 11
774774
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening)
775-
- (ss - 1)->statScore / 286
775+
- (ss - 1)->statScore / 254
776776
>= beta
777777
&& eval >= beta && eval < VALUE_TB_WIN_IN_MAX_PLY && (!ttMove || ttCapture))
778778
return beta > VALUE_TB_LOSS_IN_MAX_PLY ? (eval + beta) / 2 : eval;
779779

780780
// Step 9. Null move search with verification search (~35 Elo)
781-
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 18001
782-
&& eval >= beta && ss->staticEval >= beta - 21 * depth + 312 && !excludedMove
781+
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 16993
782+
&& eval >= beta && ss->staticEval >= beta - 19 * depth + 326 && !excludedMove
783783
&& pos.non_pawn_material(us) && ss->ply >= thisThread->nmpMinPly
784784
&& beta > VALUE_TB_LOSS_IN_MAX_PLY)
785785
{
786786
assert(eval - beta >= 0);
787787

788788
// Null move dynamic reduction based on depth and eval
789-
Depth R = std::min(int(eval - beta) / 152, 6) + depth / 3 + 4;
789+
Depth R = std::min(int(eval - beta) / 134, 6) + depth / 3 + 4;
790790

791791
ss->currentMove = Move::null();
792792
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
@@ -834,7 +834,7 @@ Value Search::Worker::search(
834834
// Step 11. ProbCut (~10 Elo)
835835
// If we have a good enough capture (or queen promotion) and a reduced search returns a value
836836
// much above beta, we can (almost) safely prune the previous move.
837-
probCutBeta = beta + 169 - 63 * improving;
837+
probCutBeta = beta + 159 - 66 * improving;
838838
if (
839839
!PvNode && depth > 3
840840
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
@@ -890,7 +890,7 @@ Value Search::Worker::search(
890890
moves_loop: // When in check, search starts here
891891

892892
// Step 12. A small Probcut idea, when we are in check (~4 Elo)
893-
probCutBeta = beta + 452;
893+
probCutBeta = beta + 420;
894894
if (ss->inCheck && !PvNode && ttCapture && (tte->bound() & BOUND_LOWER)
895895
&& tte->depth() >= depth - 4 && ttValue >= probCutBeta
896896
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
@@ -975,15 +975,15 @@ Value Search::Worker::search(
975975
// Futility pruning for captures (~2 Elo)
976976
if (!givesCheck && lmrDepth < 7 && !ss->inCheck)
977977
{
978-
Value futilityValue = ss->staticEval + 285 + 277 * lmrDepth
978+
Value futilityValue = ss->staticEval + 295 + 280 * lmrDepth
979979
+ PieceValue[capturedPiece] + captHist / 7;
980980
if (futilityValue <= alpha)
981981
continue;
982982
}
983983

984984
// SEE based pruning for captures and checks (~11 Elo)
985-
int seeHist = std::clamp(captHist / 32, -199 * depth, 199 * depth);
986-
if (!pos.see_ge(move, -203 * depth - seeHist))
985+
int seeHist = std::clamp(captHist / 32, -197 * depth, 196 * depth);
986+
if (!pos.see_ge(move, -186 * depth - seeHist))
987987
continue;
988988
}
989989
else
@@ -995,18 +995,18 @@ Value Search::Worker::search(
995995
+ thisThread->pawnHistory[pawn_structure_index(pos)][movedPiece][move.to_sq()];
996996

997997
// Continuation history based pruning (~2 Elo)
998-
if (lmrDepth < 6 && history < -4173 * depth)
998+
if (lmrDepth < 6 && history < -4081 * depth)
999999
continue;
10001000

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

1003-
lmrDepth += history / 5285;
1003+
lmrDepth += history / 4768;
10041004

10051005
Value futilityValue =
1006-
ss->staticEval + (bestValue < ss->staticEval - 54 ? 128 : 57) + 131 * lmrDepth;
1006+
ss->staticEval + (bestValue < ss->staticEval - 52 ? 134 : 54) + 142 * lmrDepth;
10071007

10081008
// Futility pruning: parent node (~13 Elo)
1009-
if (!ss->inCheck && lmrDepth < 14 && futilityValue <= alpha)
1009+
if (!ss->inCheck && lmrDepth < 13 && futilityValue <= alpha)
10101010
{
10111011
if (bestValue <= futilityValue && std::abs(bestValue) < VALUE_TB_WIN_IN_MAX_PLY
10121012
&& futilityValue < VALUE_TB_WIN_IN_MAX_PLY)
@@ -1017,7 +1017,7 @@ Value Search::Worker::search(
10171017
lmrDepth = std::max(lmrDepth, 0);
10181018

10191019
// Prune moves with negative SEE (~4 Elo)
1020-
if (!pos.see_ge(move, -27 * lmrDepth * lmrDepth))
1020+
if (!pos.see_ge(move, -28 * lmrDepth * lmrDepth))
10211021
continue;
10221022
}
10231023
}
@@ -1037,11 +1037,11 @@ Value Search::Worker::search(
10371037
// so changing them requires tests at these types of time controls.
10381038
// Recursive singular search is avoided.
10391039
if (!rootNode && move == ttMove && !excludedMove
1040-
&& depth >= 4 - (thisThread->completedDepth > 33) + ss->ttPv
1040+
&& depth >= 4 - (thisThread->completedDepth > 32) + ss->ttPv
10411041
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
10421042
&& tte->depth() >= depth - 3)
10431043
{
1044-
Value singularBeta = ttValue - (65 + 59 * (ss->ttPv && !PvNode)) * depth / 63;
1044+
Value singularBeta = ttValue - (65 + 52 * (ss->ttPv && !PvNode)) * depth / 63;
10451045
Depth singularDepth = newDepth / 2;
10461046

10471047
ss->excludedMove = move;
@@ -1099,7 +1099,7 @@ Value Search::Worker::search(
10991099
else if (PvNode && move == ttMove && move.to_sq() == prevSq
11001100
&& thisThread->captureHistory[movedPiece][move.to_sq()]
11011101
[type_of(pos.piece_on(move.to_sq()))]
1102-
> 3807)
1102+
> 4016)
11031103
extension = 1;
11041104
}
11051105

@@ -1151,10 +1151,10 @@ Value Search::Worker::search(
11511151
ss->statScore = 2 * thisThread->mainHistory[us][move.from_to()]
11521152
+ (*contHist[0])[movedPiece][move.to_sq()]
11531153
+ (*contHist[1])[movedPiece][move.to_sq()]
1154-
+ (*contHist[3])[movedPiece][move.to_sq()] - 5024;
1154+
+ (*contHist[3])[movedPiece][move.to_sq()] - 5078;
11551155

11561156
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
1157-
r -= ss->statScore / 13182;
1157+
r -= ss->statScore / 12076;
11581158

11591159
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
11601160
if (depth >= 2 && moveCount > 1 + rootNode)
@@ -1173,7 +1173,7 @@ Value Search::Worker::search(
11731173
{
11741174
// Adjust full-depth search based on LMR results - if the result
11751175
// was good enough search deeper, if it was bad enough search shallower.
1176-
const bool doDeeperSearch = value > (bestValue + 42 + 2 * newDepth); // (~1 Elo)
1176+
const bool doDeeperSearch = value > (bestValue + 40 + 2 * newDepth); // (~1 Elo)
11771177
const bool doShallowerSearch = value < bestValue + newDepth; // (~2 Elo)
11781178

11791179
newDepth += doDeeperSearch - doShallowerSearch;
@@ -1291,7 +1291,7 @@ Value Search::Worker::search(
12911291
else
12921292
{
12931293
// Reduce other moves if we have found at least one score improvement (~2 Elo)
1294-
if (depth > 2 && depth < 12 && beta < 13546 && value > -13478)
1294+
if (depth > 2 && depth < 13 && beta < 15868 && value > -14630)
12951295
depth -= 2;
12961296

12971297
assert(depth > 0);
@@ -1334,8 +1334,8 @@ Value Search::Worker::search(
13341334
// Bonus for prior countermove that caused the fail low
13351335
else if (!priorCapture && prevSq != SQ_NONE)
13361336
{
1337-
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -14761)
1338-
+ ((ss - 1)->moveCount > 11) + (!ss->inCheck && bestValue <= ss->staticEval - 142)
1337+
int bonus = (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -14455)
1338+
+ ((ss - 1)->moveCount > 10) + (!ss->inCheck && bestValue <= ss->staticEval - 130)
13391339
+ (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 77);
13401340
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
13411341
stat_bonus(depth) * bonus);
@@ -1495,7 +1495,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
14951495
if (bestValue > alpha)
14961496
alpha = bestValue;
14971497

1498-
futilityBase = ss->staticEval + 250;
1498+
futilityBase = ss->staticEval + 270;
14991499
}
15001500

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

15771577
// Do not search moves with bad enough SEE values (~5 Elo)
1578-
if (!pos.see_ge(move, -79))
1578+
if (!pos.see_ge(move, -69))
15791579
continue;
15801580
}
15811581

@@ -1643,7 +1643,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
16431643

16441644
Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) {
16451645
int reductionScale = reductions[d] * reductions[mn];
1646-
return (reductionScale + 1150 - delta * 832 / rootDelta) / 1024 + (!i && reductionScale > 1025);
1646+
return (reductionScale + 1318 - delta * 760 / rootDelta) / 1024 + (!i && reductionScale > 1066);
16471647
}
16481648

16491649
TimePoint Search::Worker::elapsed() const {
@@ -1736,7 +1736,7 @@ void update_all_stats(const Position& pos,
17361736

17371737
if (!pos.capture_stage(bestMove))
17381738
{
1739-
int bestMoveBonus = bestValue > beta + 185 ? quietMoveBonus // larger bonus
1739+
int bestMoveBonus = bestValue > beta + 165 ? quietMoveBonus // larger bonus
17401740
: stat_bonus(depth); // smaller bonus
17411741

17421742
update_quiet_stats(pos, ss, workerThread, bestMove, bestMoveBonus);

0 commit comments

Comments
 (0)