mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
VVLTC parameters tweak
Passed VVLTC with stc bounds: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 91508 W: 24212 L: 23887 D: 43409 Ptnml(0-2): 6, 7863, 29690, 8190, 5 https://tests.stockfishchess.org/tests/view/6a522f515529b8472df803a4 Passed VVLTC with ltc bounds: LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 62296 W: 16446 L: 16117 D: 29733 Ptnml(0-2): 6, 5333, 20143, 5658, 8 https://tests.stockfishchess.org/tests/view/6a52d9e65529b8472df805a5 closes https://github.com/official-stockfish/Stockfish/pull/6981 Bench: 2792255
This commit is contained in:
committed by
Joost VandeVondele
parent
86beb0f540
commit
ebcea3efe9
+112
-110
@@ -52,8 +52,8 @@
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
static constexpr std::array<int, 16> lmrDivisor = {3307, 2930, 2874, 2818, 3215, 3225, 3224, 2782,
|
||||
2858, 2919, 3088, 3275, 3180, 2868, 3006, 3599};
|
||||
static constexpr std::array<int, 16> lmrDivisor = {3637, 2787, 2761, 2939, 3171, 3347, 3147, 2762,
|
||||
2772, 3106, 3107, 3060, 3112, 2991, 3090, 3542};
|
||||
|
||||
namespace TB = Tablebases;
|
||||
|
||||
@@ -91,12 +91,12 @@ int correction_value(const Worker& w, const Position& pos, const Stack* const ss
|
||||
const int bnpcv = shared.nonpawn_correction_entry<BLACK>(pos)[us].nonPawnBlack;
|
||||
const int cntcv =
|
||||
m.is_ok()
|
||||
? 8363
|
||||
? 8761
|
||||
* ((*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
|
||||
+ (*(ss - 4)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()])
|
||||
: 64549;
|
||||
: 64049;
|
||||
|
||||
return 13345 * pcv + 9280 * micv + 11840 * (wnpcv + bnpcv) + cntcv;
|
||||
return 15341 * pcv + 10569 * micv + 12906 * (wnpcv + bnpcv) + cntcv;
|
||||
}
|
||||
|
||||
// Add correctionHistory value to raw staticEval and guarantee evaluation
|
||||
@@ -116,7 +116,7 @@ void update_correction_history(const Position& pos,
|
||||
auto& shared = workerThread.sharedHistory;
|
||||
|
||||
shared.pawn_correction_entry(pos)[us].pawn << bonus;
|
||||
shared.minor_piece_correction_entry(pos)[us].minor << bonus * 152 / 128;
|
||||
shared.minor_piece_correction_entry(pos)[us].minor << bonus * 150 / 128;
|
||||
shared.nonpawn_correction_entry<WHITE>(pos)[us].nonPawnWhite << bonus * nonPawnWeight / 128;
|
||||
shared.nonpawn_correction_entry<BLACK>(pos)[us].nonPawnBlack << bonus * nonPawnWeight / 128;
|
||||
|
||||
@@ -124,8 +124,8 @@ void update_correction_history(const Position& pos,
|
||||
{
|
||||
const Square to = m.to_sq();
|
||||
const Piece pc = pos.piece_on(to);
|
||||
(*(ss - 2)->continuationCorrectionHistory)[pc][to] << bonus * 136 / 128;
|
||||
(*(ss - 4)->continuationCorrectionHistory)[pc][to] << bonus * 68 / 128;
|
||||
(*(ss - 2)->continuationCorrectionHistory)[pc][to] << bonus * 130 / 128;
|
||||
(*(ss - 4)->continuationCorrectionHistory)[pc][to] << bonus * 70 / 128;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,11 +322,11 @@ bool Search::Worker::iterative_deepening() {
|
||||
int searchAgainCounter = 0;
|
||||
bool uciPvSent = false;
|
||||
|
||||
lowPlyHistory.fill(100);
|
||||
lowPlyHistory.fill(102);
|
||||
|
||||
for (Color c : {WHITE, BLACK})
|
||||
for (int i = 0; i < UINT_16_HISTORY_SIZE; i++)
|
||||
mainHistory[c][i] = mainHistory[c][i] * 789 / 1024;
|
||||
mainHistory[c][i] = mainHistory[c][i] * 729 / 1024;
|
||||
|
||||
// Iterative deepening loop until requested to stop or the target depth is reached
|
||||
while (rootDepth + 1 < MAX_PLY && !threads.stop
|
||||
@@ -372,13 +372,13 @@ bool Search::Worker::iterative_deepening() {
|
||||
selDepth = 0;
|
||||
|
||||
// Reset aspiration window starting size
|
||||
delta = 5 + threadIdx % 8 + std::abs(rootMoves[pvIdx].meanSquaredScore) / 10588;
|
||||
delta = 5 + threadIdx % 8 + std::abs(rootMoves[pvIdx].meanSquaredScore) / 10193;
|
||||
Value avg = rootMoves[pvIdx].averageScore;
|
||||
alpha = std::max(avg - delta, -VALUE_INFINITE);
|
||||
beta = std::min(avg + delta, VALUE_INFINITE);
|
||||
|
||||
// Adjust optimism based on root move's averageScore
|
||||
optimism[us] = 137 * avg / (std::abs(avg) + 81);
|
||||
optimism[us] = 114 * avg / (std::abs(avg) + 85);
|
||||
optimism[~us] = -optimism[us];
|
||||
|
||||
// Start with a small aspiration window and, in the case of a fail
|
||||
@@ -435,7 +435,7 @@ bool Search::Worker::iterative_deepening() {
|
||||
else
|
||||
break;
|
||||
|
||||
delta += 44 * delta / 128;
|
||||
delta += 47 * delta / 128;
|
||||
|
||||
assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
|
||||
}
|
||||
@@ -569,22 +569,23 @@ bool Search::Worker::iterative_deepening() {
|
||||
{
|
||||
u64 nodesEffort = rootMoves[0].effort * 100000 / std::max(u64(1), u64(nodes));
|
||||
|
||||
double fallingEval = (11.87 + 2.21 * (mainThread->bestPreviousAverageScore - bestValue)
|
||||
+ 1.0 * (mainThread->iterValue[iterIdx] - bestValue))
|
||||
double fallingEval = (11.48 + 2.30 * (mainThread->bestPreviousAverageScore - bestValue)
|
||||
+ 1.1 * (mainThread->iterValue[iterIdx] - bestValue))
|
||||
/ 100.0;
|
||||
fallingEval = std::clamp(fallingEval, 0.572, 1.708);
|
||||
fallingEval = std::clamp(fallingEval, 0.576, 1.728);
|
||||
|
||||
// If the bestMove is stable over several iterations, reduce time accordingly
|
||||
timeReduction =
|
||||
std::clamp(interpolate(double(rootDepth - lastBestMoveDepth), 5.0, 18.0, 0.65, 1.55),
|
||||
0.65, 1.55);
|
||||
timeReduction = std::clamp(
|
||||
interpolate(double(rootDepth - lastBestMoveDepth), 4.96, 18.79, 0.639, 1.712), 0.629,
|
||||
1.544);
|
||||
|
||||
double reduction = (1.48 + mainThread->previousTimeReduction) / (2.157 * timeReduction);
|
||||
double reduction =
|
||||
(1.468 + mainThread->previousTimeReduction) / (2.284 * timeReduction);
|
||||
|
||||
double bestMoveInstability = 1.096 + 2.29 * totBestMoveChanges / threads.size();
|
||||
double bestMoveInstability = 1.077 + 2.229 * totBestMoveChanges / threads.size();
|
||||
|
||||
double highBestMoveEffort = std::clamp(
|
||||
interpolate(i64(nodesEffort), i64(79219), i64(101822), 0.924, 0.71), 0.71, 0.924);
|
||||
interpolate(i64(nodesEffort), i64(75800), i64(104510), 0.969, 0.714), 0.693, 0.838);
|
||||
|
||||
double totalTime = mainThread->tm.optimum() * fallingEval * reduction
|
||||
* bestMoveInstability * highBestMoveEffort;
|
||||
@@ -674,11 +675,11 @@ void Search::Worker::undo_null_move(Position& pos) { pos.undo_null_move(); }
|
||||
// Reset histories, usually before a new game
|
||||
void Search::Worker::clear() {
|
||||
mainHistory.fill(-5);
|
||||
captureHistory.fill(-699);
|
||||
captureHistory.fill(-742);
|
||||
|
||||
// Each thread is responsible for clearing their part of shared history
|
||||
sharedHistory.correctionHistory.clear_range(-6, numaThreadIdx, numaTotal);
|
||||
sharedHistory.pawnHistory.clear_range(-1262, numaThreadIdx, numaTotal);
|
||||
sharedHistory.correctionHistory.clear_range(-5, numaThreadIdx, numaTotal);
|
||||
sharedHistory.pawnHistory.clear_range(-1338, numaThreadIdx, numaTotal);
|
||||
|
||||
ttMoveHistory = 0;
|
||||
|
||||
@@ -690,10 +691,10 @@ void Search::Worker::clear() {
|
||||
for (StatsType c : {NoCaptures, Captures})
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h.fill(-552);
|
||||
h.fill(-586);
|
||||
|
||||
for (usize i = 1; i < reductions.size(); ++i)
|
||||
reductions[i] = int(2834 / 128.0 * std::log(i));
|
||||
reductions[i] = int(2872 / 128.0 * std::log(i));
|
||||
|
||||
refreshTable.clear(network[numaAccessToken]);
|
||||
}
|
||||
@@ -849,7 +850,7 @@ Value Search::Worker::search(
|
||||
// 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)
|
||||
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 166)
|
||||
depth--;
|
||||
|
||||
// At non-PV nodes we check for an early TT cutoff
|
||||
@@ -863,11 +864,11 @@ Value Search::Worker::search(
|
||||
{
|
||||
// Bonus for a quiet ttMove that fails high
|
||||
if (!ttCapture)
|
||||
update_quiet_histories(pos, ss, *this, ttData.move, std::min(114 * depth, 724));
|
||||
update_quiet_histories(pos, ss, *this, ttData.move, std::min(112 * depth, 695));
|
||||
|
||||
// Extra penalty for early quiet moves of the previous ply
|
||||
if (prevSq != SQ_NONE && (ss - 1)->moveCount < 4 && !priorCapture)
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -2187);
|
||||
if (prevSq != SQ_NONE && (ss - 1)->moveCount < 5 && !priorCapture)
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -2210);
|
||||
}
|
||||
|
||||
// Partial workaround for the graph history interaction problem
|
||||
@@ -959,8 +960,8 @@ Value Search::Worker::search(
|
||||
// Use static evaluation difference to improve quiet move ordering
|
||||
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
|
||||
{
|
||||
int evalDiff = std::clamp(-int((ss - 1)->staticEval + ss->staticEval), -183, 180) + 62;
|
||||
mainHistory[~us][((ss - 1)->currentMove).raw()] << evalDiff * 10;
|
||||
int evalDiff = std::clamp(-int((ss - 1)->staticEval + ss->staticEval), -189, 194) + 60;
|
||||
mainHistory[~us][((ss - 1)->currentMove).raw()] << evalDiff * 11;
|
||||
if (!ttHit && type_of(pos.piece_on(prevSq)) != PAWN
|
||||
&& ((ss - 1)->currentMove).type_of() != PROMOTION)
|
||||
sharedHistory.pawn_entry(pos)[pos.piece_on(prevSq)][prevSq] << evalDiff * 13;
|
||||
@@ -970,27 +971,27 @@ Value Search::Worker::search(
|
||||
// Step 7. Razoring
|
||||
// If eval is really low, skip search entirely and return the qsearch value.
|
||||
// For PvNodes, we must have a guard against mates being returned.
|
||||
if (!PvNode && eval < alpha - 465 - 300 * depth * depth)
|
||||
if (!PvNode && eval < alpha - 483 - 318 * depth * depth)
|
||||
return qsearch<NonPV>(pos, ss, alpha, beta);
|
||||
|
||||
// Step 8. Futility pruning: child node
|
||||
// The depth condition is important for mate finding.
|
||||
if (!ss->ttPv && depth < 17 && eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta)
|
||||
if (!ss->ttPv && depth < 19 && eval >= beta && (!ttData.move || ttCapture) && !is_loss(beta)
|
||||
&& !is_win(eval))
|
||||
{
|
||||
Value futilityMult = std::min(40 + depth * 4, 80);
|
||||
Value futilityMult = std::min(45 + depth * 4, 85);
|
||||
futilityMult -= 20 * !ss->ttHit;
|
||||
|
||||
Value futilityMargin = futilityMult * depth
|
||||
- (2934 * improving + 343 * opponentWorsening) * futilityMult / 1024
|
||||
+ std::abs(correctionValue) / 182069;
|
||||
- (2789 * improving + 335 * opponentWorsening) * futilityMult / 1024
|
||||
+ std::abs(correctionValue) / 198435;
|
||||
|
||||
if (eval - futilityMargin >= beta)
|
||||
return (716 * beta + 308 * eval) / 1024;
|
||||
return (661 * beta + 363 * eval) / 1024;
|
||||
}
|
||||
|
||||
// Step 9. Null move search with verification search
|
||||
if (cutNode && ss->staticEval >= beta - 14 * depth - 45 * improving + 374 && !excludedMove
|
||||
if (cutNode && ss->staticEval >= beta - 13 * depth - 47 * improving + 365 && !excludedMove
|
||||
&& pos.non_pawn_material(us) && ss->ply >= nmpMinPly && !is_loss(beta))
|
||||
{
|
||||
assert((ss - 1)->currentMove != Move::null());
|
||||
@@ -1035,7 +1036,7 @@ Value Search::Worker::search(
|
||||
// Step 11. ProbCut
|
||||
// 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 + 214 - 59 * improving;
|
||||
probCutBeta = beta + 241 - 64 * improving;
|
||||
if (depth >= 3
|
||||
&& !is_decisive(beta)
|
||||
// If value from transposition table is lower than probCutBeta, don't attempt
|
||||
@@ -1045,7 +1046,7 @@ Value Search::Worker::search(
|
||||
assert(probCutBeta < VALUE_INFINITE && probCutBeta > beta);
|
||||
|
||||
MovePicker mp(pos, ttData.move, probCutBeta - ss->staticEval, &captureHistory);
|
||||
Depth probCutDepth = depth - 4 - improving;
|
||||
Depth probCutDepth = depth - (improving ? 5 : 3);
|
||||
|
||||
while ((move = mp.next_move()) != Move::none())
|
||||
{
|
||||
@@ -1144,7 +1145,7 @@ moves_loop: // When in check, search starts here
|
||||
// Increase reduction for ttPv nodes (*Scaler)
|
||||
// Larger values scale well
|
||||
if (ss->ttPv)
|
||||
r += 1006;
|
||||
r += 929;
|
||||
|
||||
// Step 14. Pruning at shallow depths.
|
||||
// Depth conditions are important for mate finding.
|
||||
@@ -1163,10 +1164,10 @@ moves_loop: // When in check, search starts here
|
||||
int captHist = captureHistory[movedPiece][move.to_sq()][type_of(capturedPiece)];
|
||||
|
||||
// Futility pruning for captures
|
||||
if (!givesCheck && lmrDepth < 7)
|
||||
if (!givesCheck && lmrDepth < 8)
|
||||
{
|
||||
Value futilityValue = ss->staticEval + 231 + 232 * lmrDepth
|
||||
+ PieceValue[capturedPiece] + 131 * captHist / 1024;
|
||||
Value futilityValue = ss->staticEval + 234 + 247 * lmrDepth
|
||||
+ PieceValue[capturedPiece] + 134 * captHist / 1024;
|
||||
|
||||
if (futilityValue <= alpha)
|
||||
continue;
|
||||
@@ -1174,7 +1175,7 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
// SEE based pruning for captures and checks
|
||||
// Avoid pruning sacrifices of our last piece for stalemate
|
||||
int margin = 175 * depth + captHist * 34 / 1024;
|
||||
int margin = 177 * depth + captHist * 34 / 1024;
|
||||
if ((alpha >= VALUE_DRAW || pos.non_pawn_material(us) != PieceValue[movedPiece])
|
||||
&& !pos.see_ge(move, -margin))
|
||||
continue;
|
||||
@@ -1187,15 +1188,15 @@ moves_loop: // When in check, search starts here
|
||||
+ sharedHistory.pawn_entry(pos)[movedPiece][move.to_sq()];
|
||||
|
||||
// Continuation history based pruning
|
||||
if (history < -4313 * depth)
|
||||
if (history < -4136 * depth)
|
||||
continue;
|
||||
|
||||
history += 64 * mainHistory[us][move.raw()] / 32;
|
||||
history += 69 * mainHistory[us][move.raw()] / 32;
|
||||
|
||||
// (*Scaler): Generally, lower divisors scale well
|
||||
lmrDepth += history / lmrDivisor[dIndex];
|
||||
|
||||
Value futilityValue = ss->staticEval + 40 + 138 * !bestMove + 117 * lmrDepth
|
||||
Value futilityValue = ss->staticEval + 39 + 127 * !bestMove + 119 * lmrDepth
|
||||
+ 90 * (ss->staticEval > alpha);
|
||||
|
||||
// Futility pruning: parent node
|
||||
@@ -1212,7 +1213,7 @@ moves_loop: // When in check, search starts here
|
||||
lmrDepth = std::max(lmrDepth, 0);
|
||||
|
||||
// Prune moves with negative SEE
|
||||
if (!pos.see_ge(move, -25 * lmrDepth * lmrDepth))
|
||||
if (!pos.see_ge(move, -23 * lmrDepth * lmrDepth))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1231,7 +1232,7 @@ moves_loop: // When in check, search starts here
|
||||
&& is_valid(ttData.value) && !is_decisive(ttData.value) && (ttData.bound & BOUND_LOWER)
|
||||
&& ttData.depth >= depth - 3 && !is_shuffling(move, ss, pos))
|
||||
{
|
||||
Value singularBeta = ttData.value - (60 + 70 * (ss->ttPv && !PvNode)) * depth / 59;
|
||||
Value singularBeta = ttData.value - (59 + 66 * (ss->ttPv && !PvNode)) * depth / 63;
|
||||
Depth singularDepth = newDepth / 2;
|
||||
|
||||
ss->excludedMove = move;
|
||||
@@ -1240,11 +1241,11 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
if (value < singularBeta)
|
||||
{
|
||||
int corrValAdj = std::abs(correctionValue) / 194822;
|
||||
int doubleMargin = -3 + 201 * PvNode - 157 * !ttCapture - corrValAdj
|
||||
- 1081 * ttMoveHistory / 117824 - (ss->ply > rootDepth) * 41;
|
||||
int tripleMargin = 72 + 306 * PvNode - 188 * !ttCapture + 84 * ss->ttPv - corrValAdj
|
||||
- (ss->ply > rootDepth) * 45;
|
||||
int corrValAdj = std::abs(correctionValue) / 198368;
|
||||
int doubleMargin = -2 + 204 * PvNode - 152 * !ttCapture - corrValAdj
|
||||
- 1175 * ttMoveHistory / 114178 - (ss->ply > rootDepth) * 38;
|
||||
int tripleMargin = 70 + 279 * PvNode - 188 * !ttCapture + 81 * ss->ttPv - corrValAdj
|
||||
- (ss->ply > rootDepth) * 43;
|
||||
|
||||
extension =
|
||||
1 + (value < singularBeta - doubleMargin) + (value < singularBeta - tripleMargin);
|
||||
@@ -1260,7 +1261,7 @@ moves_loop: // When in check, search starts here
|
||||
// subtree by returning a softbound.
|
||||
else if (value >= beta && !is_decisive(value))
|
||||
{
|
||||
ttMoveHistory << -442 - 108 * depth;
|
||||
ttMoveHistory << -421 - 110 * depth;
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1291,43 +1292,44 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
// Decrease reduction for PvNodes (*Scaler)
|
||||
if (ss->ttPv)
|
||||
r -= 2766 + PvNode * 1017 + (ttData.value > alpha) * 838
|
||||
+ (ttData.depth >= depth) * (923 + cutNode * 955);
|
||||
r -= 3023 + PvNode * 1004 + (ttData.value > alpha) * 885
|
||||
+ (ttData.depth >= depth) * (816 + cutNode * 940);
|
||||
|
||||
r += 714; // Base reduction offset to compensate for other tweaks
|
||||
r -= moveCount * 62;
|
||||
r -= std::abs(correctionValue) / 26131;
|
||||
r += 697; // Base reduction offset to compensate for other tweaks
|
||||
r -= moveCount * 65;
|
||||
r -= std::abs(correctionValue) / 26310;
|
||||
|
||||
// Increase reduction for cut nodes
|
||||
if (cutNode)
|
||||
r += 3995 + 1059 * !ttData.move;
|
||||
r += 4026 + 933 * !ttData.move;
|
||||
|
||||
// Increase reduction if ttMove is a capture
|
||||
if (ttCapture)
|
||||
r += 1039;
|
||||
r += 1079;
|
||||
|
||||
// Increase reduction if next ply has a lot of fail high
|
||||
if ((ss + 1)->cutoffCnt > 1)
|
||||
r += 236 + 1079 * ((ss + 1)->cutoffCnt > 2) + 1143 * allNode;
|
||||
r += 264 + 1095 * ((ss + 1)->cutoffCnt > 2) + 1138 * allNode;
|
||||
|
||||
// For first picked move (ttMove) reduce reduction
|
||||
else if (move == ttData.move)
|
||||
r -= 2016;
|
||||
r -= 2179;
|
||||
|
||||
if (capture)
|
||||
ss->statScore = 809 * int(PieceValue[pos.captured_piece()]) / 128
|
||||
ss->statScore = 873 * int(PieceValue[pos.captured_piece()]) / 128
|
||||
+ captureHistory[movedPiece][move.to_sq()][type_of(pos.captured_piece())];
|
||||
else
|
||||
ss->statScore = 2 * mainHistory[us][move.raw()]
|
||||
+ (*contHist[0])[movedPiece][move.to_sq()]
|
||||
+ (*contHist[1])[movedPiece][move.to_sq()];
|
||||
ss->statScore =
|
||||
(2252 * mainHistory[us][move.raw()] + 1126 * (*contHist[0])[movedPiece][move.to_sq()]
|
||||
+ 1093 * (*contHist[1])[movedPiece][move.to_sq()])
|
||||
/ 1024;
|
||||
|
||||
// Decrease/increase reduction for moves with a good/bad history
|
||||
r -= ss->statScore * 445 / 4096;
|
||||
r -= ss->statScore * 439 / 4096;
|
||||
|
||||
// Scale up reductions for expected ALL nodes
|
||||
if (allNode)
|
||||
r += r * 272 / (256 * depth + 285);
|
||||
r += r * 276 / (256 * depth + 268);
|
||||
|
||||
// Step 17. Late moves reduction / extension (LMR)
|
||||
if (depth >= 2 && moveCount > 1)
|
||||
@@ -1349,8 +1351,8 @@ 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 = d < newDepth && value > bestValue + 52;
|
||||
const bool doShallowerSearch = value < bestValue + 9;
|
||||
const bool doDeeperSearch = d < newDepth && value > bestValue + 53;
|
||||
const bool doShallowerSearch = value < bestValue + 8;
|
||||
|
||||
newDepth += doDeeperSearch - doShallowerSearch;
|
||||
|
||||
@@ -1358,7 +1360,7 @@ moves_loop: // When in check, search starts here
|
||||
value = -search<NonPV>(pos, ss + 1, -(alpha + 1), -alpha, newDepth, !cutNode);
|
||||
|
||||
// Post LMR continuation history updates
|
||||
update_continuation_histories(ss, movedPiece, move.to_sq(), 1415);
|
||||
update_continuation_histories(ss, movedPiece, move.to_sq(), 1334);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1367,11 +1369,11 @@ moves_loop: // When in check, search starts here
|
||||
{
|
||||
// Increase reduction if ttMove is not present
|
||||
if (!ttData.move)
|
||||
r += 1085;
|
||||
r += 1127;
|
||||
|
||||
// Note that if expected reduction is high, we reduce search depth here
|
||||
value = -search<NonPV>(pos, ss + 1, -(alpha + 1), -alpha,
|
||||
newDepth - (r > 5039) - (r > 5223 && newDepth > 2), !cutNode);
|
||||
newDepth - (r > 5234) - (r > 5487 && newDepth > 2), !cutNode);
|
||||
}
|
||||
|
||||
// For PV nodes only, do a full PV search on the first move or after a fail high,
|
||||
@@ -1499,8 +1501,8 @@ moves_loop: // When in check, search starts here
|
||||
}
|
||||
|
||||
// Reduce other moves if we have found at least one score improvement
|
||||
if (depth > 2 && depth < 13 && !is_decisive(value))
|
||||
depth -= 2;
|
||||
if (depth > 3 && depth < 12 && !is_decisive(value))
|
||||
depth -= 3;
|
||||
|
||||
assert(depth > 0);
|
||||
alpha = value; // Update alpha! Always alpha < beta
|
||||
@@ -1539,31 +1541,31 @@ moves_loop: // When in check, search starts here
|
||||
update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth,
|
||||
ttData.move, PvNode);
|
||||
if (!PvNode)
|
||||
ttMoveHistory << (bestMove == ttData.move ? 792 : -779);
|
||||
ttMoveHistory << (bestMove == ttData.move ? 918 : -747);
|
||||
}
|
||||
|
||||
// Bonus for prior quiet countermove that caused the fail low
|
||||
else if (!priorCapture && prevSq != SQ_NONE)
|
||||
{
|
||||
int bonusScale = -245;
|
||||
int bonusScale = -241;
|
||||
bonusScale -= (ss - 1)->statScore / 98;
|
||||
bonusScale += std::min(59 * depth, 430);
|
||||
bonusScale += 191 * ((ss - 1)->moveCount > 8);
|
||||
bonusScale += 143 * (!ss->inCheck && bestValue <= ss->staticEval - 103);
|
||||
bonusScale += 151 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 78);
|
||||
bonusScale += std::min(59 * depth, 420);
|
||||
bonusScale += 186 * ((ss - 1)->moveCount > 9);
|
||||
bonusScale += 142 * (!ss->inCheck && bestValue <= ss->staticEval - 106);
|
||||
bonusScale += 159 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 68);
|
||||
|
||||
bonusScale = std::max(bonusScale, 0);
|
||||
|
||||
// scaledBonus ranges from 0 to roughly 2.3M, overflows happen for multipliers larger than 900
|
||||
const int scaledBonus = std::min(141 * depth - 82, 1472) * bonusScale;
|
||||
const int scaledBonus = std::min(150 * depth - 85, 1337) * bonusScale;
|
||||
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
|
||||
scaledBonus * 236 / 16384);
|
||||
scaledBonus * 263 / 16384);
|
||||
|
||||
mainHistory[~us][((ss - 1)->currentMove).raw()] << scaledBonus * 234 / 32768;
|
||||
mainHistory[~us][((ss - 1)->currentMove).raw()] << scaledBonus * 215 / 32768;
|
||||
|
||||
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
|
||||
sharedHistory.pawn_entry(pos)[pos.piece_on(prevSq)][prevSq] << scaledBonus * 322 / 8192;
|
||||
sharedHistory.pawn_entry(pos)[pos.piece_on(prevSq)][prevSq] << scaledBonus * 324 / 8192;
|
||||
}
|
||||
|
||||
// Bonus for prior capture countermove that caused the fail low
|
||||
@@ -1571,7 +1573,7 @@ moves_loop: // When in check, search starts here
|
||||
{
|
||||
Piece capturedPiece = pos.captured_piece();
|
||||
assert(capturedPiece != NO_PIECE);
|
||||
captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)] << 901;
|
||||
captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)] << 892;
|
||||
}
|
||||
|
||||
if (PvNode)
|
||||
@@ -1600,7 +1602,7 @@ moves_loop: // When in check, search starts here
|
||||
auto bonus =
|
||||
std::clamp(int(bestValue - ss->staticEval) * depth * (bestMove ? 12 : 18) / 128,
|
||||
-CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4);
|
||||
update_correction_history(pos, ss, *this, 1114 * bonus / 1024);
|
||||
update_correction_history(pos, ss, *this, 1061 * bonus / 1024);
|
||||
}
|
||||
|
||||
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
||||
@@ -1712,7 +1714,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
|
||||
if (bestValue >= beta)
|
||||
{
|
||||
if (!is_decisive(bestValue))
|
||||
bestValue = (467 * bestValue + 557 * beta) / 1024;
|
||||
bestValue = (441 * bestValue + 583 * beta) / 1024;
|
||||
|
||||
if (!ss->ttHit)
|
||||
ttWriter.write(posKey, VALUE_NONE, false, BOUND_LOWER, DEPTH_UNSEARCHED,
|
||||
@@ -1723,7 +1725,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
|
||||
if (bestValue > alpha)
|
||||
alpha = bestValue;
|
||||
|
||||
futilityBase = ss->staticEval + 335;
|
||||
futilityBase = ss->staticEval + 306;
|
||||
}
|
||||
|
||||
const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory};
|
||||
@@ -1836,7 +1838,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
|
||||
}
|
||||
|
||||
if (!is_decisive(bestValue) && bestValue > beta)
|
||||
bestValue = (481 * bestValue + 543 * beta) / 1024;
|
||||
bestValue = (462 * bestValue + 562 * beta) / 1024;
|
||||
|
||||
// Save gathered info in transposition table. The static evaluation
|
||||
// is saved as it was before adjustment by correction history.
|
||||
@@ -1851,7 +1853,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
|
||||
|
||||
int Search::Worker::reduction(bool i, Depth d, int mn, int delta) const {
|
||||
int reductionScale = reductions[d] * reductions[mn];
|
||||
return reductionScale - delta * 617 / rootDelta + !i * reductionScale * 194 / 512 + 1027;
|
||||
return reductionScale - delta * 577 / rootDelta + !i * reductionScale * 197 / 512 + 982;
|
||||
}
|
||||
|
||||
// elapsed() returns the time elapsed since the search started. If the
|
||||
@@ -1933,8 +1935,8 @@ void update_all_stats(const Position& pos,
|
||||
PieceType capturedPiece;
|
||||
|
||||
int bonus =
|
||||
std::min(134 * depth - 79, 1572) + 382 * (bestMove == ttMove) + (ss - 1)->statScore / 30;
|
||||
int malus = std::min(1005 * depth - 205, 2218);
|
||||
std::min(133 * depth - 81, 1487) + 364 * (bestMove == ttMove) + (ss - 1)->statScore / 28;
|
||||
int malus = std::min(968 * depth - 235, 2244);
|
||||
|
||||
if (!PvNode)
|
||||
// Important: don't remove the cast to a 64-bit number else the multiplication
|
||||
@@ -1943,13 +1945,13 @@ void update_all_stats(const Position& pos,
|
||||
|
||||
if (!pos.capture_stage(bestMove))
|
||||
{
|
||||
update_quiet_histories(pos, ss, workerThread, bestMove, bonus * 824 / 1024);
|
||||
update_quiet_histories(pos, ss, workerThread, bestMove, bonus * 899 / 1024);
|
||||
|
||||
int actualMalus = malus * 1136 / 1024;
|
||||
int actualMalus = malus * 1159 / 1024;
|
||||
// Decrease stats for all non-best quiet moves
|
||||
for (Move move : quietsSearched)
|
||||
{
|
||||
actualMalus = actualMalus * 956 / 1024;
|
||||
actualMalus = actualMalus * 921 / 1024;
|
||||
update_quiet_histories(pos, ss, workerThread, move, -actualMalus);
|
||||
}
|
||||
}
|
||||
@@ -1957,20 +1959,20 @@ void update_all_stats(const Position& pos,
|
||||
{
|
||||
// Increase stats for the best move in case it was a capture move
|
||||
capturedPiece = type_of(pos.piece_on(bestMove.to_sq()));
|
||||
captureHistory[movedPiece][bestMove.to_sq()][capturedPiece] << bonus * 1366 / 1024;
|
||||
captureHistory[movedPiece][bestMove.to_sq()][capturedPiece] << bonus * 1427 / 1024;
|
||||
}
|
||||
|
||||
// Extra penalty for a quiet early move that was not a TT move in
|
||||
// previous ply when it gets refuted.
|
||||
if (prevSq != SQ_NONE && ((ss - 1)->moveCount == 1 + (ss - 1)->ttHit) && !pos.captured_piece())
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -malus * 683 / 1024);
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -malus * 713 / 1024);
|
||||
|
||||
// Decrease stats for all non-best capture moves
|
||||
for (Move move : capturesSearched)
|
||||
{
|
||||
movedPiece = pos.moved_piece(move);
|
||||
capturedPiece = type_of(pos.piece_on(move.to_sq()));
|
||||
captureHistory[movedPiece][move.to_sq()][capturedPiece] << -malus * 1518 / 1024;
|
||||
captureHistory[movedPiece][move.to_sq()][capturedPiece] << -malus * 1489 / 1024;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1979,10 +1981,10 @@ void update_all_stats(const Position& pos,
|
||||
// the current move and the moves played in previous plies.
|
||||
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
|
||||
static constexpr std::array<ConthistBonus, 6> conthist_bonuses = {
|
||||
{{1, 1040}, {2, 780}, {3, 300}, {4, 537}, {5, 129}, {6, 423}}};
|
||||
{{1, 1040}, {2, 780}, {3, 290}, {4, 502}, {5, 132}, {6, 418}}};
|
||||
|
||||
// Multipliers for positive history consistency
|
||||
constexpr int CMHCMultipliers[] = {96, 113, 101, 105, 127, 121, 126};
|
||||
constexpr int CMHCMultipliers[] = {94, 103, 110, 106, 119, 126, 121};
|
||||
int positiveCount = 0;
|
||||
|
||||
for (const auto [i, weight] : conthist_bonuses)
|
||||
@@ -1998,7 +2000,7 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
|
||||
positiveCount++;
|
||||
|
||||
int multiplier = CMHCMultipliers[positiveCount];
|
||||
historyEntry << (bonus * weight * multiplier / 131072) + 71 * (i < 2);
|
||||
historyEntry << (bonus * weight * multiplier / 131072) + 73 * (i < 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2012,12 +2014,12 @@ void update_quiet_histories(
|
||||
workerThread.mainHistory[us][move.raw()] << bonus; // Untuned to prevent duplicate effort
|
||||
|
||||
if (ss->ply < LOW_PLY_HISTORY_SIZE)
|
||||
workerThread.lowPlyHistory[ss->ply][move.raw()] << bonus * 663 / 1024;
|
||||
workerThread.lowPlyHistory[ss->ply][move.raw()] << bonus * 712 / 1024;
|
||||
|
||||
update_continuation_histories(ss, pos.moved_piece(move), move.to_sq(), bonus * 820 / 1024);
|
||||
update_continuation_histories(ss, pos.moved_piece(move), move.to_sq(), bonus * 750 / 1024);
|
||||
|
||||
workerThread.sharedHistory.pawn_entry(pos)[pos.moved_piece(move)][move.to_sq()]
|
||||
<< bonus * (bonus > -7 ? 1038 : 525) / 1024;
|
||||
<< bonus * (bonus > -4 ? 1104 : 459) / 1024;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user