mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
VVLTC search tune
Tuned with 85k games at VVLTC. VVLTC 1st sprt: https://tests.stockfishchess.org/tests/view/6648b836308cceea45533ad7 LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 14880 W: 3890 L: 3652 D: 7338 Ptnml(0-2): 0, 1255, 4694, 1489, 2 VVLTC 2nd sprt: https://tests.stockfishchess.org/tests/view/6648c34f308cceea45533b4f LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 24984 W: 6502 L: 6235 D: 12247 Ptnml(0-2): 1, 2178, 7867, 2445, 1 closes https://github.com/official-stockfish/Stockfish/pull/5264 Bench: 1198142
This commit is contained in:
parent
2694fce928
commit
99f1bacfd6
1 changed files with 42 additions and 42 deletions
|
@ -59,9 +59,9 @@ static constexpr double EvalLevel[10] = {0.981, 0.956, 0.895, 0.949, 0.913,
|
|||
|
||||
// Futility margin
|
||||
Value futility_margin(Depth d, bool noTtCutNode, bool improving, bool oppWorsening) {
|
||||
Value futilityMult = 131 - 48 * noTtCutNode;
|
||||
Value improvingDeduction = 2 * improving * futilityMult;
|
||||
Value worseningDeduction = 330 * oppWorsening * futilityMult / 1024;
|
||||
Value futilityMult = 127 - 48 * noTtCutNode;
|
||||
Value improvingDeduction = 65 * improving * futilityMult / 32;
|
||||
Value worseningDeduction = 334 * oppWorsening * futilityMult / 1024;
|
||||
|
||||
return futilityMult * d - improvingDeduction - worseningDeduction;
|
||||
}
|
||||
|
@ -73,15 +73,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) / 7179;
|
||||
v += cv * std::abs(cv) / 6047;
|
||||
return std::clamp(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::clamp(200 * d - 280, 16, 1495); }
|
||||
int stat_bonus(Depth d) { return std::clamp(187 * d - 288, 17, 1548); }
|
||||
|
||||
// History and stats update malus, based on depth
|
||||
int stat_malus(Depth d) { return (d < 4 ? 586 * d - 284 : 1639); }
|
||||
int stat_malus(Depth d) { return (d < 4 ? 630 * d - 281 : 1741); }
|
||||
|
||||
// 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); }
|
||||
|
@ -311,12 +311,12 @@ void Search::Worker::iterative_deepening() {
|
|||
|
||||
// Reset aspiration window starting size
|
||||
Value avg = rootMoves[pvIdx].averageScore;
|
||||
delta = 10 + avg * avg / 9474;
|
||||
delta = 10 + avg * avg / 9828;
|
||||
alpha = std::max(avg - delta, -VALUE_INFINITE);
|
||||
beta = std::min(avg + delta, VALUE_INFINITE);
|
||||
|
||||
// Adjust optimism based on root move's averageScore (~4 Elo)
|
||||
optimism[us] = 117 * avg / (std::abs(avg) + 88);
|
||||
optimism[us] = 116 * avg / (std::abs(avg) + 84);
|
||||
optimism[~us] = -optimism[us];
|
||||
|
||||
// Start with a small aspiration window and, in the case of a fail
|
||||
|
@ -503,10 +503,10 @@ void Search::Worker::clear() {
|
|||
for (StatsType c : {NoCaptures, Captures})
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h->fill(-62);
|
||||
h->fill(-60);
|
||||
|
||||
for (size_t i = 1; i < reductions.size(); ++i)
|
||||
reductions[i] = int((21.19 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
|
||||
reductions[i] = int((21.69 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
|
||||
|
||||
refreshTable.clear(networks);
|
||||
}
|
||||
|
@ -739,7 +739,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(-12 * int((ss - 1)->staticEval + ss->staticEval), -1749, 1584);
|
||||
int bonus = std::clamp(-11 * int((ss - 1)->staticEval + ss->staticEval), -1729, 1517);
|
||||
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)
|
||||
|
@ -762,7 +762,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 - 473 - (308 - 138 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
|
||||
if (eval < alpha - 474 - (326 - 139 * ((ss + 1)->cutoffCnt > 3)) * depth * depth)
|
||||
{
|
||||
value = qsearch<NonPV>(pos, ss, alpha - 1, alpha);
|
||||
if (value < alpha)
|
||||
|
@ -773,21 +773,21 @@ Value Search::Worker::search(
|
|||
// The depth condition is important for mate finding.
|
||||
if (!ss->ttPv && depth < 11
|
||||
&& eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening)
|
||||
- (ss - 1)->statScore / 258
|
||||
- (ss - 1)->statScore / 252
|
||||
>= beta
|
||||
&& eval >= beta && eval < VALUE_TB_WIN_IN_MAX_PLY && (!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 < 16079
|
||||
&& eval >= beta && ss->staticEval >= beta - 21 * depth + 324 && !excludedMove
|
||||
if (!PvNode && (ss - 1)->currentMove != Move::null() && (ss - 1)->statScore < 15246
|
||||
&& eval >= beta && ss->staticEval >= beta - 21 * depth + 366 && !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 + 5;
|
||||
Depth R = std::min(int(eval - beta) / 152, 6) + depth / 3 + 5;
|
||||
|
||||
ss->currentMove = Move::null();
|
||||
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
|
||||
|
@ -835,7 +835,7 @@ Value Search::Worker::search(
|
|||
// Step 11. ProbCut (~10 Elo)
|
||||
// If we have a good enough capture (or queen promotion) and a reduced search returns a value
|
||||
// much above beta, we can (almost) safely prune the previous move.
|
||||
probCutBeta = beta + 177 - 65 * improving;
|
||||
probCutBeta = beta + 176 - 65 * improving;
|
||||
if (
|
||||
!PvNode && depth > 3
|
||||
&& std::abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
|
||||
|
@ -891,7 +891,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 + 428;
|
||||
probCutBeta = beta + 440;
|
||||
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)
|
||||
|
@ -975,15 +975,15 @@ moves_loop: // When in check, search starts here
|
|||
// Futility pruning for captures (~2 Elo)
|
||||
if (!givesCheck && lmrDepth < 7 && !ss->inCheck)
|
||||
{
|
||||
Value futilityValue = ss->staticEval + 305 + 272 * lmrDepth
|
||||
Value futilityValue = ss->staticEval + 276 + 256 * lmrDepth
|
||||
+ PieceValue[capturedPiece] + captHist / 7;
|
||||
if (futilityValue <= alpha)
|
||||
continue;
|
||||
}
|
||||
|
||||
// SEE based pruning for captures and checks (~11 Elo)
|
||||
int seeHist = std::clamp(captHist / 32, -185 * depth, 182 * depth);
|
||||
if (!pos.see_ge(move, -176 * depth - seeHist))
|
||||
int seeHist = std::clamp(captHist / 32, -177 * depth, 175 * depth);
|
||||
if (!pos.see_ge(move, -183 * depth - seeHist))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
@ -994,18 +994,18 @@ moves_loop: // When in check, search starts here
|
|||
+ thisThread->pawnHistory[pawn_structure_index(pos)][movedPiece][move.to_sq()];
|
||||
|
||||
// Continuation history based pruning (~2 Elo)
|
||||
if (lmrDepth < 6 && history < -4360 * depth)
|
||||
if (lmrDepth < 6 && history < -4076 * depth)
|
||||
continue;
|
||||
|
||||
history += 2 * thisThread->mainHistory[us][move.from_to()];
|
||||
|
||||
lmrDepth += history / 4507;
|
||||
lmrDepth += history / 4401;
|
||||
|
||||
Value futilityValue =
|
||||
ss->staticEval + (bestValue < ss->staticEval - 54 ? 142 : 55) + 132 * lmrDepth;
|
||||
ss->staticEval + (bestValue < ss->staticEval - 53 ? 151 : 57) + 140 * lmrDepth;
|
||||
|
||||
// Futility pruning: parent node (~13 Elo)
|
||||
if (!ss->inCheck && lmrDepth < 11 && futilityValue <= alpha)
|
||||
if (!ss->inCheck && lmrDepth < 10 && futilityValue <= alpha)
|
||||
{
|
||||
if (bestValue <= futilityValue && std::abs(bestValue) < VALUE_TB_WIN_IN_MAX_PLY
|
||||
&& futilityValue < VALUE_TB_WIN_IN_MAX_PLY)
|
||||
|
@ -1016,7 +1016,7 @@ moves_loop: // When in check, search starts here
|
|||
lmrDepth = std::max(lmrDepth, 0);
|
||||
|
||||
// Prune moves with negative SEE (~4 Elo)
|
||||
if (!pos.see_ge(move, -27 * lmrDepth * lmrDepth))
|
||||
if (!pos.see_ge(move, -26 * lmrDepth * lmrDepth))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1036,11 +1036,11 @@ moves_loop: // When in check, search starts here
|
|||
// 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 > 33) + ss->ttPv
|
||||
&& depth >= 4 - (thisThread->completedDepth > 35) + ss->ttPv
|
||||
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
|
||||
&& tte->depth() >= depth - 3)
|
||||
{
|
||||
Value singularBeta = ttValue - (59 + 49 * (ss->ttPv && !PvNode)) * depth / 64;
|
||||
Value singularBeta = ttValue - (57 + 50 * (ss->ttPv && !PvNode)) * depth / 64;
|
||||
Depth singularDepth = newDepth / 2;
|
||||
|
||||
ss->excludedMove = move;
|
||||
|
@ -1050,14 +1050,14 @@ moves_loop: // When in check, search starts here
|
|||
|
||||
if (value < singularBeta)
|
||||
{
|
||||
int doubleMargin = 285 * PvNode - 228 * !ttCapture;
|
||||
int doubleMargin = 298 * PvNode - 209 * !ttCapture;
|
||||
int tripleMargin =
|
||||
121 + 238 * PvNode - 259 * !ttCapture + 117 * (ss->ttPv || !ttCapture);
|
||||
117 + 252 * PvNode - 270 * !ttCapture + 111 * (ss->ttPv || !ttCapture);
|
||||
|
||||
extension = 1 + (value < singularBeta - doubleMargin)
|
||||
+ (value < singularBeta - tripleMargin);
|
||||
|
||||
depth += ((!PvNode) && (depth < 14));
|
||||
depth += ((!PvNode) && (depth < 15));
|
||||
}
|
||||
|
||||
// Multi-cut pruning
|
||||
|
@ -1092,7 +1092,7 @@ moves_loop: // When in check, search starts here
|
|||
else if (PvNode && move == ttMove && move.to_sq() == prevSq
|
||||
&& thisThread->captureHistory[movedPiece][move.to_sq()]
|
||||
[type_of(pos.piece_on(move.to_sq()))]
|
||||
> 4041)
|
||||
> 3748)
|
||||
extension = 1;
|
||||
}
|
||||
|
||||
|
@ -1143,10 +1143,10 @@ moves_loop: // When in check, search starts here
|
|||
|
||||
ss->statScore = 2 * thisThread->mainHistory[us][move.from_to()]
|
||||
+ (*contHist[0])[movedPiece][move.to_sq()]
|
||||
+ (*contHist[1])[movedPiece][move.to_sq()] - 5313;
|
||||
+ (*contHist[1])[movedPiece][move.to_sq()] - 5266;
|
||||
|
||||
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
|
||||
r -= ss->statScore / (16145 - std::min(depth, 15) * 102);
|
||||
r -= ss->statScore / (14519 - std::min(depth, 15) * 103);
|
||||
|
||||
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
|
||||
if (depth >= 2 && moveCount > 1 + rootNode)
|
||||
|
@ -1165,7 +1165,7 @@ moves_loop: // When in check, search starts here
|
|||
{
|
||||
// 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 + 41 + 2 * newDepth); // (~1 Elo)
|
||||
const bool doDeeperSearch = value > (bestValue + 40 + 2 * newDepth); // (~1 Elo)
|
||||
const bool doShallowerSearch = value < bestValue + newDepth; // (~2 Elo)
|
||||
|
||||
newDepth += doDeeperSearch - doShallowerSearch;
|
||||
|
@ -1326,9 +1326,9 @@ moves_loop: // When in check, search starts here
|
|||
// Bonus for prior countermove that caused the fail low
|
||||
else if (!priorCapture && prevSq != SQ_NONE)
|
||||
{
|
||||
int bonus = (depth > 4) + (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -14323)
|
||||
+ ((ss - 1)->moveCount > 10) + (!ss->inCheck && bestValue <= ss->staticEval - 120)
|
||||
+ (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 76);
|
||||
int bonus = (depth > 4) + (depth > 5) + (PvNode || cutNode) + ((ss - 1)->statScore < -13241)
|
||||
+ ((ss - 1)->moveCount > 10) + (!ss->inCheck && bestValue <= ss->staticEval - 127)
|
||||
+ (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 74);
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
|
||||
stat_bonus(depth) * bonus);
|
||||
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()]
|
||||
|
@ -1494,7 +1494,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
|||
if (bestValue > alpha)
|
||||
alpha = bestValue;
|
||||
|
||||
futilityBase = ss->staticEval + 259;
|
||||
futilityBase = ss->staticEval + 264;
|
||||
}
|
||||
|
||||
const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory,
|
||||
|
@ -1566,11 +1566,11 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
|||
+ (*contHist[1])[pos.moved_piece(move)][move.to_sq()]
|
||||
+ thisThread->pawnHistory[pawn_structure_index(pos)][pos.moved_piece(move)]
|
||||
[move.to_sq()]
|
||||
<= 4057)
|
||||
<= 4348)
|
||||
continue;
|
||||
|
||||
// Do not search moves with bad enough SEE values (~5 Elo)
|
||||
if (!pos.see_ge(move, -68))
|
||||
if (!pos.see_ge(move, -63))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1636,7 +1636,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
|||
|
||||
Depth Search::Worker::reduction(bool i, Depth d, int mn, int delta) {
|
||||
int reductionScale = reductions[d] * reductions[mn];
|
||||
return (reductionScale + 1284 - delta * 755 / rootDelta) / 1024 + (!i && reductionScale > 1133);
|
||||
return (reductionScale + 1147 - delta * 755 / rootDelta) / 1024 + (!i && reductionScale > 1125);
|
||||
}
|
||||
|
||||
// elapsed() returns the time elapsed since the search started. If the
|
||||
|
|
Loading…
Add table
Reference in a new issue