mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
VVLTC tweak
Passed VVLTC with STC bounds: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 60796 W: 15908 L: 15609 D: 29279 Ptnml(0-2): 6, 5598, 18889, 5901, 4 https://tests.stockfishchess.org/tests/view/68a1fbfeb6fb3300203bbc5c Passed VVLTC with LTC bounds: LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 24914 W: 6528 L: 6256 D: 12130 Ptnml(0-2): 4, 2263, 7648, 2541, 1 https://tests.stockfishchess.org/tests/view/68a211aeb6fb3300203bbca7 closes https://github.com/official-stockfish/Stockfish/pull/6241 Bench: 2130122
This commit is contained in:
committed by
Joost VandeVondele
parent
8ecfc3c89d
commit
7fe46b5a70
+108
-107
@@ -81,9 +81,9 @@ int correction_value(const Worker& w, const Position& pos, const Stack* const ss
|
||||
const auto bnpcv = w.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us];
|
||||
const auto cntcv =
|
||||
m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
|
||||
: 0;
|
||||
: 8;
|
||||
|
||||
return 8867 * pcv + 8136 * micv + 10757 * (wnpcv + bnpcv) + 7232 * cntcv;
|
||||
return 9536 * pcv + 8494 * micv + 10132 * (wnpcv + bnpcv) + 7156 * cntcv;
|
||||
}
|
||||
|
||||
// Add correctionHistory value to raw staticEval and guarantee evaluation
|
||||
@@ -99,10 +99,10 @@ void update_correction_history(const Position& pos,
|
||||
const Move m = (ss - 1)->currentMove;
|
||||
const Color us = pos.side_to_move();
|
||||
|
||||
static constexpr int nonPawnWeight = 165;
|
||||
const int nonPawnWeight = 165;
|
||||
|
||||
workerThread.pawnCorrectionHistory[pawn_correction_history_index(pos)][us] << bonus;
|
||||
workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 153 / 128;
|
||||
workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 145 / 128;
|
||||
workerThread.nonPawnCorrectionHistory[non_pawn_index<WHITE>(pos)][WHITE][us]
|
||||
<< bonus * nonPawnWeight / 128;
|
||||
workerThread.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us]
|
||||
@@ -110,7 +110,7 @@ void update_correction_history(const Position& pos,
|
||||
|
||||
if (m.is_ok())
|
||||
(*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
|
||||
<< bonus * 153 / 128;
|
||||
<< bonus * 137 / 128;
|
||||
}
|
||||
|
||||
// Add a small random component to draw evaluations to avoid 3-fold blindness
|
||||
@@ -286,7 +286,7 @@ void Search::Worker::iterative_deepening() {
|
||||
|
||||
int searchAgainCounter = 0;
|
||||
|
||||
lowPlyHistory.fill(89);
|
||||
lowPlyHistory.fill(97);
|
||||
|
||||
// Iterative deepening loop until requested to stop or the target depth is reached
|
||||
while (++rootDepth < MAX_PLY && !threads.stop
|
||||
@@ -322,13 +322,13 @@ void Search::Worker::iterative_deepening() {
|
||||
selDepth = 0;
|
||||
|
||||
// Reset aspiration window starting size
|
||||
delta = 5 + threadIdx % 8 + std::abs(rootMoves[pvIdx].meanSquaredScore) / 11131;
|
||||
delta = 5 + threadIdx % 8 + std::abs(rootMoves[pvIdx].meanSquaredScore) / 9000;
|
||||
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] = 136 * avg / (std::abs(avg) + 93);
|
||||
optimism[us] = 137 * avg / (std::abs(avg) + 91);
|
||||
optimism[~us] = -optimism[us];
|
||||
|
||||
// Start with a small aspiration window and, in the case of a fail
|
||||
@@ -457,29 +457,29 @@ void Search::Worker::iterative_deepening() {
|
||||
rootMoves[0].effort * 100000 / std::max(size_t(1), size_t(nodes));
|
||||
|
||||
double fallingEval =
|
||||
(11.396 + 2.035 * (mainThread->bestPreviousAverageScore - bestValue)
|
||||
+ 0.968 * (mainThread->iterValue[iterIdx] - bestValue))
|
||||
(11.325 + 2.115 * (mainThread->bestPreviousAverageScore - bestValue)
|
||||
+ 0.987 * (mainThread->iterValue[iterIdx] - bestValue))
|
||||
/ 100.0;
|
||||
fallingEval = std::clamp(fallingEval, 0.5786, 1.6752);
|
||||
fallingEval = std::clamp(fallingEval, 0.5688, 1.5698);
|
||||
|
||||
// If the bestMove is stable over several iterations, reduce time accordingly
|
||||
double k = 0.527;
|
||||
double center = lastBestMoveDepth + 11;
|
||||
timeReduction = 0.8 + 0.84 / (1.077 + std::exp(-k * (completedDepth - center)));
|
||||
double k = 0.5189;
|
||||
double center = lastBestMoveDepth + 11.57;
|
||||
timeReduction = 0.723 + 0.79 / (1.104 + std::exp(-k * (completedDepth - center)));
|
||||
double reduction =
|
||||
(1.4540 + mainThread->previousTimeReduction) / (2.1593 * timeReduction);
|
||||
double bestMoveInstability = 0.9929 + 1.8519 * totBestMoveChanges / threads.size();
|
||||
(1.455 + mainThread->previousTimeReduction) / (2.2375 * timeReduction);
|
||||
double bestMoveInstability = 1.04 + 1.8956 * totBestMoveChanges / threads.size();
|
||||
|
||||
double totalTime =
|
||||
mainThread->tm.optimum() * fallingEval * reduction * bestMoveInstability;
|
||||
|
||||
// Cap used time in case of a single legal move for a better viewer experience
|
||||
if (rootMoves.size() == 1)
|
||||
totalTime = std::min(500.0, totalTime);
|
||||
totalTime = std::min(502.0, totalTime);
|
||||
|
||||
auto elapsedTime = elapsed();
|
||||
|
||||
if (completedDepth >= 10 && nodesEffort >= 97056 && elapsedTime > totalTime * 0.6540
|
||||
if (completedDepth >= 10 && nodesEffort >= 92425 && elapsedTime > totalTime * 0.666
|
||||
&& !mainThread->ponder)
|
||||
threads.stop = true;
|
||||
|
||||
@@ -494,7 +494,7 @@ void Search::Worker::iterative_deepening() {
|
||||
threads.stop = true;
|
||||
}
|
||||
else
|
||||
threads.increaseDepth = mainThread->ponder || elapsedTime <= totalTime * 0.5138;
|
||||
threads.increaseDepth = mainThread->ponder || elapsedTime <= totalTime * 0.503;
|
||||
}
|
||||
|
||||
mainThread->iterValue[iterIdx] = bestValue;
|
||||
@@ -544,9 +544,9 @@ 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(64);
|
||||
captureHistory.fill(-753);
|
||||
pawnHistory.fill(-1275);
|
||||
mainHistory.fill(68);
|
||||
captureHistory.fill(-689);
|
||||
pawnHistory.fill(-1238);
|
||||
pawnCorrectionHistory.fill(5);
|
||||
minorPieceCorrectionHistory.fill(0);
|
||||
nonPawnCorrectionHistory.fill(0);
|
||||
@@ -561,10 +561,10 @@ void Search::Worker::clear() {
|
||||
for (StatsType c : {NoCaptures, Captures})
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h.fill(-494);
|
||||
h.fill(-529);
|
||||
|
||||
for (size_t i = 1; i < reductions.size(); ++i)
|
||||
reductions[i] = int(2782 / 128.0 * std::log(i));
|
||||
reductions[i] = int(2809 / 128.0 * std::log(i));
|
||||
|
||||
refreshTable.clear(networks[numaAccessToken]);
|
||||
}
|
||||
@@ -687,16 +687,16 @@ Value Search::Worker::search(
|
||||
// Bonus for a quiet ttMove that fails high
|
||||
if (!ttCapture)
|
||||
update_quiet_histories(pos, ss, *this, ttData.move,
|
||||
std::min(127 * depth - 74, 1063));
|
||||
std::min(130 * depth - 71, 1043));
|
||||
|
||||
// Extra penalty for early quiet moves of the previous ply
|
||||
if (prevSq != SQ_NONE && (ss - 1)->moveCount <= 3 && !priorCapture)
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -2128);
|
||||
if (prevSq != SQ_NONE && (ss - 1)->moveCount < 4 && !priorCapture)
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -2142);
|
||||
}
|
||||
|
||||
// Partial workaround for the graph history interaction problem
|
||||
// For high rule50 counts don't produce transposition table cutoffs.
|
||||
if (pos.rule50_count() < 91)
|
||||
if (pos.rule50_count() < 96)
|
||||
{
|
||||
if (depth >= 8 && ttData.move && pos.pseudo_legal(ttData.move) && pos.legal(ttData.move)
|
||||
&& !is_decisive(ttData.value))
|
||||
@@ -809,12 +809,12 @@ Value Search::Worker::search(
|
||||
// Use static evaluation difference to improve quiet move ordering
|
||||
if (((ss - 1)->currentMove).is_ok() && !(ss - 1)->inCheck && !priorCapture)
|
||||
{
|
||||
int bonus = std::clamp(-10 * int((ss - 1)->staticEval + ss->staticEval), -1979, 1561) + 630;
|
||||
mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus * 935 / 1024;
|
||||
int bonus = std::clamp(-10 * int((ss - 1)->staticEval + ss->staticEval), -2023, 1563) + 583;
|
||||
mainHistory[~us][((ss - 1)->currentMove).from_to()] << bonus * 944 / 1024;
|
||||
if (!ttHit && type_of(pos.piece_on(prevSq)) != PAWN
|
||||
&& ((ss - 1)->currentMove).type_of() != PROMOTION)
|
||||
pawnHistory[pawn_history_index(pos)][pos.piece_on(prevSq)][prevSq]
|
||||
<< bonus * 1428 / 1024;
|
||||
<< bonus * 1438 / 1024;
|
||||
}
|
||||
|
||||
// Set up the improving flag, which is true if current static evaluation is
|
||||
@@ -824,28 +824,28 @@ Value Search::Worker::search(
|
||||
improving = ss->staticEval > (ss - 2)->staticEval;
|
||||
opponentWorsening = ss->staticEval > -(ss - 1)->staticEval;
|
||||
|
||||
if (priorReduction >= (depth < 10 ? 1 : 3) && !opponentWorsening)
|
||||
if (priorReduction >= (depth < 10 ? 2 : 3) && !opponentWorsening)
|
||||
depth++;
|
||||
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 177)
|
||||
if (priorReduction >= 2 && depth >= 2 && ss->staticEval + (ss - 1)->staticEval > 173)
|
||||
depth--;
|
||||
|
||||
// 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 - 495 - 290 * depth * depth)
|
||||
if (!PvNode && eval < alpha - 514 - 294 * depth * depth)
|
||||
return qsearch<NonPV>(pos, ss, alpha, beta);
|
||||
|
||||
// Step 8. Futility pruning: child node
|
||||
// The depth condition is important for mate finding.
|
||||
{
|
||||
auto futility_margin = [&](Depth d) {
|
||||
Value futilityMult = 90 - 20 * (cutNode && !ss->ttHit);
|
||||
Value futilityMult = 91 - 21 * (!ss->ttHit);
|
||||
|
||||
return futilityMult * d //
|
||||
- improving * futilityMult * 2 //
|
||||
- opponentWorsening * futilityMult / 3 //
|
||||
+ (ss - 1)->statScore / 356 //
|
||||
+ std::abs(correctionValue) / 171290;
|
||||
return futilityMult * d //
|
||||
- 2094 * improving * futilityMult / 1024 //
|
||||
- 1324 * opponentWorsening * futilityMult / 4096 //
|
||||
+ (ss - 1)->statScore / 331 //
|
||||
+ std::abs(correctionValue) / 158105;
|
||||
};
|
||||
|
||||
if (!ss->ttPv && depth < 14 && eval - futility_margin(depth) >= beta && eval >= beta
|
||||
@@ -854,13 +854,13 @@ Value Search::Worker::search(
|
||||
}
|
||||
|
||||
// Step 9. Null move search with verification search
|
||||
if (cutNode && ss->staticEval >= beta - 19 * depth + 403 && !excludedMove
|
||||
if (cutNode && ss->staticEval >= beta - 18 * depth + 390 && !excludedMove
|
||||
&& pos.non_pawn_material(us) && ss->ply >= nmpMinPly && !is_loss(beta))
|
||||
{
|
||||
assert((ss - 1)->currentMove != Move::null());
|
||||
|
||||
// Null move dynamic reduction based on depth
|
||||
Depth R = 7 + depth / 3;
|
||||
Depth R = 6 + depth / 3;
|
||||
|
||||
ss->currentMove = Move::null();
|
||||
ss->continuationHistory = &continuationHistory[0][0][NO_PIECE][0];
|
||||
@@ -904,7 +904,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 + 215 - 60 * improving;
|
||||
probCutBeta = beta + 224 - 64 * improving;
|
||||
if (depth >= 3
|
||||
&& !is_decisive(beta)
|
||||
// If value from transposition table is lower than probCutBeta, don't attempt
|
||||
@@ -914,7 +914,7 @@ Value Search::Worker::search(
|
||||
assert(probCutBeta < VALUE_INFINITE && probCutBeta > beta);
|
||||
|
||||
MovePicker mp(pos, ttData.move, probCutBeta - ss->staticEval, &captureHistory);
|
||||
Depth dynamicReduction = (ss->staticEval - beta) / 300;
|
||||
Depth dynamicReduction = (ss->staticEval - beta) / 306;
|
||||
Depth probCutDepth = std::max(depth - 5 - dynamicReduction, 0);
|
||||
|
||||
while ((move = mp.next_move()) != Move::none())
|
||||
@@ -955,7 +955,7 @@ Value Search::Worker::search(
|
||||
moves_loop: // When in check, search starts here
|
||||
|
||||
// Step 12. A small Probcut idea
|
||||
probCutBeta = beta + 417;
|
||||
probCutBeta = beta + 418;
|
||||
if ((ttData.bound & BOUND_LOWER) && ttData.depth >= depth - 4 && ttData.value >= probCutBeta
|
||||
&& !is_decisive(beta) && is_valid(ttData.value) && !is_decisive(ttData.value))
|
||||
return probCutBeta;
|
||||
@@ -1019,7 +1019,7 @@ moves_loop: // When in check, search starts here
|
||||
// Smaller or even negative value is better for short time controls
|
||||
// Bigger value is better for long time controls
|
||||
if (ss->ttPv)
|
||||
r += 931;
|
||||
r += 946;
|
||||
|
||||
// Step 14. Pruning at shallow depth.
|
||||
// Depth conditions are important for mate finding.
|
||||
@@ -1041,15 +1041,15 @@ moves_loop: // When in check, search starts here
|
||||
if (!givesCheck && lmrDepth < 7 && !ss->inCheck)
|
||||
{
|
||||
|
||||
Value futilityValue = ss->staticEval + 232 + 224 * lmrDepth
|
||||
+ PieceValue[capturedPiece] + 131 * captHist / 1024;
|
||||
Value futilityValue = ss->staticEval + 231 + 211 * lmrDepth
|
||||
+ PieceValue[capturedPiece] + 130 * captHist / 1024;
|
||||
|
||||
if (futilityValue <= alpha)
|
||||
continue;
|
||||
}
|
||||
|
||||
// SEE based pruning for captures and checks
|
||||
int margin = std::clamp(158 * depth + captHist / 31, 0, 283 * depth);
|
||||
int margin = std::clamp(157 * depth + captHist / 29, 0, 279 * depth);
|
||||
if (!pos.see_ge(move, -margin))
|
||||
{
|
||||
bool mayStalemateTrap =
|
||||
@@ -1071,16 +1071,16 @@ moves_loop: // When in check, search starts here
|
||||
+ pawnHistory[pawn_history_index(pos)][movedPiece][move.to_sq()];
|
||||
|
||||
// Continuation history based pruning
|
||||
if (history < -4361 * depth)
|
||||
if (history < -4312 * depth)
|
||||
continue;
|
||||
|
||||
history += 71 * mainHistory[us][move.from_to()] / 32;
|
||||
history += 76 * mainHistory[us][move.from_to()] / 32;
|
||||
|
||||
lmrDepth += history / 3233;
|
||||
lmrDepth += history / 3220;
|
||||
|
||||
Value baseFutility = (bestMove ? 46 : 230);
|
||||
Value baseFutility = (bestMove ? 47 : 218);
|
||||
Value futilityValue =
|
||||
ss->staticEval + baseFutility + 131 * lmrDepth + 91 * (ss->staticEval > alpha);
|
||||
ss->staticEval + baseFutility + 134 * lmrDepth + 90 * (ss->staticEval > alpha);
|
||||
|
||||
// Futility pruning: parent node
|
||||
// (*Scaler): Generally, more frequent futility pruning
|
||||
@@ -1096,7 +1096,7 @@ moves_loop: // When in check, search starts here
|
||||
lmrDepth = std::max(lmrDepth, 0);
|
||||
|
||||
// Prune moves with negative SEE
|
||||
if (!pos.see_ge(move, -26 * lmrDepth * lmrDepth))
|
||||
if (!pos.see_ge(move, -27 * lmrDepth * lmrDepth))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1116,7 +1116,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)
|
||||
{
|
||||
Value singularBeta = ttData.value - (56 + 79 * (ss->ttPv && !PvNode)) * depth / 58;
|
||||
Value singularBeta = ttData.value - (56 + 81 * (ss->ttPv && !PvNode)) * depth / 60;
|
||||
Depth singularDepth = newDepth / 2;
|
||||
|
||||
ss->excludedMove = move;
|
||||
@@ -1125,11 +1125,11 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
if (value < singularBeta)
|
||||
{
|
||||
int corrValAdj = std::abs(correctionValue) / 249096;
|
||||
int doubleMargin = 4 + 205 * PvNode - 223 * !ttCapture - corrValAdj
|
||||
- 959 * ttMoveHistory / 131072 - (ss->ply > rootDepth) * 45;
|
||||
int tripleMargin = 80 + 276 * PvNode - 249 * !ttCapture + 86 * ss->ttPv - corrValAdj
|
||||
- (ss->ply * 2 > rootDepth * 3) * 53;
|
||||
int corrValAdj = std::abs(correctionValue) / 229958;
|
||||
int doubleMargin = -4 + 198 * PvNode - 212 * !ttCapture - corrValAdj
|
||||
- 921 * ttMoveHistory / 127649 - (ss->ply > rootDepth) * 45;
|
||||
int tripleMargin = 76 + 308 * PvNode - 250 * !ttCapture + 92 * ss->ttPv - corrValAdj
|
||||
- (ss->ply * 2 > rootDepth * 3) * 52;
|
||||
|
||||
extension =
|
||||
1 + (value < singularBeta - doubleMargin) + (value < singularBeta - tripleMargin);
|
||||
@@ -1172,35 +1172,35 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
// Decrease reduction for PvNodes (*Scaler)
|
||||
if (ss->ttPv)
|
||||
r -= 2510 + PvNode * 963 + (ttData.value > alpha) * 916
|
||||
+ (ttData.depth >= depth) * (943 + cutNode * 1180);
|
||||
r -= 2618 + PvNode * 991 + (ttData.value > alpha) * 903
|
||||
+ (ttData.depth >= depth) * (978 + cutNode * 1051);
|
||||
|
||||
// These reduction adjustments have no proven non-linear scaling
|
||||
|
||||
r += 679 - 6 * msb(depth); // Base reduction offset to compensate for other tweaks
|
||||
r -= moveCount * (67 - 2 * msb(depth));
|
||||
r -= std::abs(correctionValue) / 27160;
|
||||
r += 700 - 6 * msb(depth); // Base reduction offset to compensate for other tweaks
|
||||
r -= moveCount * (64 - 2 * msb(depth));
|
||||
r -= std::abs(correctionValue) / 30450;
|
||||
|
||||
// Increase reduction for cut nodes
|
||||
if (cutNode)
|
||||
r += 2998 + 2 * msb(depth) + (948 + 14 * msb(depth)) * !ttData.move;
|
||||
r += 3092 + 2 * msb(depth) + (980 + 15 * msb(depth)) * !ttData.move;
|
||||
|
||||
// Increase reduction if ttMove is a capture
|
||||
if (ttCapture)
|
||||
r += 1402 - 39 * msb(depth);
|
||||
r += 1467 - 40 * msb(depth);
|
||||
|
||||
// Increase reduction if next ply has a lot of fail high
|
||||
if ((ss + 1)->cutoffCnt > 2)
|
||||
r += 925 + 33 * msb(depth) + allNode * (701 + 224 * msb(depth));
|
||||
r += 1041 + 34 * msb(depth) + allNode * (752 + 226 * msb(depth));
|
||||
|
||||
r += (ss + 1)->quietMoveStreak * 51;
|
||||
r += (ss + 1)->quietMoveStreak * 50;
|
||||
|
||||
// For first picked move (ttMove) reduce reduction
|
||||
if (move == ttData.move)
|
||||
r -= 2121 + 28 * msb(depth);
|
||||
r -= 2096 + 27 * msb(depth);
|
||||
|
||||
if (capture)
|
||||
ss->statScore = 782 * int(PieceValue[pos.captured_piece()]) / 128
|
||||
ss->statScore = 803 * int(PieceValue[pos.captured_piece()]) / 128
|
||||
+ captureHistory[movedPiece][move.to_sq()][type_of(pos.captured_piece())];
|
||||
else
|
||||
ss->statScore = 2 * mainHistory[us][move.from_to()]
|
||||
@@ -1208,7 +1208,7 @@ moves_loop: // When in check, search starts here
|
||||
+ (*contHist[1])[movedPiece][move.to_sq()];
|
||||
|
||||
// Decrease/increase reduction for moves with a good/bad history
|
||||
r -= ss->statScore * (729 - 12 * msb(depth)) / 8192;
|
||||
r -= ss->statScore * (734 - 12 * msb(depth)) / 8192;
|
||||
|
||||
// Step 17. Late moves reduction / extension (LMR)
|
||||
if (depth >= 2 && moveCount > 1)
|
||||
@@ -1218,7 +1218,8 @@ moves_loop: // When in check, search starts here
|
||||
// beyond the first move depth.
|
||||
// To prevent problems when the max value is less than the min value,
|
||||
// std::clamp has been replaced by a more robust implementation.
|
||||
Depth d = std::max(1, std::min(newDepth - r / 1024, newDepth + 1 + PvNode)) + PvNode;
|
||||
Depth d =
|
||||
std::max(1, std::min(newDepth - r / 1024, newDepth + (PvNode ? 2 : 1))) + PvNode;
|
||||
|
||||
ss->reduction = newDepth - d;
|
||||
value = -search<NonPV>(pos, ss + 1, -(alpha + 1), -alpha, d, true);
|
||||
@@ -1240,7 +1241,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(), 1412);
|
||||
update_continuation_histories(ss, movedPiece, move.to_sq(), 1365);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1249,14 +1250,14 @@ moves_loop: // When in check, search starts here
|
||||
{
|
||||
// Increase reduction if ttMove is not present
|
||||
if (!ttData.move)
|
||||
r += 1199 + 35 * msb(depth);
|
||||
r += 1178 + 35 * msb(depth);
|
||||
|
||||
if (depth <= 4)
|
||||
r += 1150;
|
||||
if (depth < 5)
|
||||
r += 1080;
|
||||
|
||||
// Note that if expected reduction is high, we reduce search depth here
|
||||
value = -search<NonPV>(pos, ss + 1, -(alpha + 1), -alpha,
|
||||
newDepth - (r > 3200) - (r > 4600 && newDepth > 2), !cutNode);
|
||||
newDepth - (r > 3212) - (r > 4784 && newDepth > 2), !cutNode);
|
||||
}
|
||||
|
||||
// For PV nodes only, do a full PV search on the first move or after a fail high,
|
||||
@@ -1361,7 +1362,7 @@ moves_loop: // When in check, search starts here
|
||||
}
|
||||
|
||||
// Reduce other moves if we have found at least one score improvement
|
||||
if (depth > 2 && depth < 16 && !is_decisive(value))
|
||||
if (depth > 2 && depth < 14 && !is_decisive(value))
|
||||
depth -= 2;
|
||||
|
||||
assert(depth > 0);
|
||||
@@ -1401,31 +1402,31 @@ moves_loop: // When in check, search starts here
|
||||
update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth,
|
||||
ttData.move);
|
||||
if (!PvNode)
|
||||
ttMoveHistory << (bestMove == ttData.move ? 811 : -848);
|
||||
ttMoveHistory << (bestMove == ttData.move ? 809 : -865);
|
||||
}
|
||||
|
||||
// Bonus for prior quiet countermove that caused the fail low
|
||||
else if (!priorCapture && prevSq != SQ_NONE)
|
||||
{
|
||||
int bonusScale = -215;
|
||||
bonusScale += std::min(-(ss - 1)->statScore / 103, 337);
|
||||
bonusScale += std::min(64 * depth, 552);
|
||||
bonusScale += 177 * ((ss - 1)->moveCount > 8);
|
||||
bonusScale += 141 * (!ss->inCheck && bestValue <= ss->staticEval - 94);
|
||||
bonusScale += 141 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 76);
|
||||
int bonusScale = -228;
|
||||
bonusScale += std::min(-(ss - 1)->statScore / 104, 322);
|
||||
bonusScale += std::min(63 * depth, 508);
|
||||
bonusScale += 184 * ((ss - 1)->moveCount > 8);
|
||||
bonusScale += 143 * (!ss->inCheck && bestValue <= ss->staticEval - 92);
|
||||
bonusScale += 149 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 70);
|
||||
|
||||
bonusScale = std::max(bonusScale, 0);
|
||||
|
||||
const int scaledBonus = std::min(155 * depth - 88, 1416) * bonusScale;
|
||||
const int scaledBonus = std::min(144 * depth - 92, 1365) * bonusScale;
|
||||
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
|
||||
scaledBonus * 397 / 32768);
|
||||
scaledBonus * 400 / 32768);
|
||||
|
||||
mainHistory[~us][((ss - 1)->currentMove).from_to()] << scaledBonus * 224 / 32768;
|
||||
mainHistory[~us][((ss - 1)->currentMove).from_to()] << scaledBonus * 220 / 32768;
|
||||
|
||||
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
|
||||
pawnHistory[pawn_history_index(pos)][pos.piece_on(prevSq)][prevSq]
|
||||
<< scaledBonus * 1127 / 32768;
|
||||
<< scaledBonus * 1164 / 32768;
|
||||
}
|
||||
|
||||
// Bonus for prior capture countermove that caused the fail low
|
||||
@@ -1433,7 +1434,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)] << 1042;
|
||||
captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)] << 964;
|
||||
}
|
||||
|
||||
if (PvNode)
|
||||
@@ -1644,11 +1645,11 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
|
||||
if (!capture
|
||||
&& (*contHist[0])[pos.moved_piece(move)][move.to_sq()]
|
||||
+ pawnHistory[pawn_history_index(pos)][pos.moved_piece(move)][move.to_sq()]
|
||||
<= 5868)
|
||||
<= 5475)
|
||||
continue;
|
||||
|
||||
// Do not search moves with bad enough SEE values
|
||||
if (!pos.see_ge(move, -74))
|
||||
if (!pos.see_ge(move, -78))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1721,7 +1722,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) const {
|
||||
int reductionScale = reductions[d] * reductions[mn];
|
||||
return reductionScale - delta * 731 / rootDelta + !i * reductionScale * 216 / 512 + 1089;
|
||||
return reductionScale - delta * 757 / rootDelta + !i * reductionScale * 218 / 512 + 1200;
|
||||
}
|
||||
|
||||
// elapsed() returns the time elapsed since the search started. If the
|
||||
@@ -1816,17 +1817,17 @@ void update_all_stats(const Position& pos,
|
||||
Piece movedPiece = pos.moved_piece(bestMove);
|
||||
PieceType capturedPiece;
|
||||
|
||||
int bonus = std::min(170 * depth - 87, 1598) + 332 * (bestMove == ttMove);
|
||||
int quietMalus = std::min(743 * depth - 180, 2287) - 33 * quietsSearched.size();
|
||||
int captureMalus = std::min(708 * depth - 148, 2287) - 29 * capturesSearched.size();
|
||||
int bonus = std::min(151 * depth - 91, 1730) + 302 * (bestMove == ttMove);
|
||||
int quietMalus = std::min(798 * depth - 175, 2268) - 33 * quietsSearched.size();
|
||||
int captureMalus = std::min(757 * depth - 134, 2129) - 28 * capturesSearched.size();
|
||||
|
||||
if (!pos.capture_stage(bestMove))
|
||||
{
|
||||
update_quiet_histories(pos, ss, workerThread, bestMove, bonus * 978 / 1024);
|
||||
update_quiet_histories(pos, ss, workerThread, bestMove, bonus * 957 / 1024);
|
||||
|
||||
// Decrease stats for all non-best quiet moves
|
||||
for (Move move : quietsSearched)
|
||||
update_quiet_histories(pos, ss, workerThread, move, -quietMalus * 1115 / 1024);
|
||||
update_quiet_histories(pos, ss, workerThread, move, -quietMalus * 1208 / 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1839,14 +1840,14 @@ void update_all_stats(const Position& pos,
|
||||
// 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,
|
||||
-captureMalus * 622 / 1024);
|
||||
-captureMalus * 594 / 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] << -captureMalus * 1431 / 1024;
|
||||
captureHistory[movedPiece][move.to_sq()][capturedPiece] << -captureMalus * 1366 / 1024;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1854,8 +1855,8 @@ void update_all_stats(const Position& pos,
|
||||
// Updates histories of the move pairs formed by moves
|
||||
// at ply -1, -2, -3, -4, and -6 with current move.
|
||||
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
|
||||
static constexpr std::array<ConthistBonus, 6> conthist_bonuses = {
|
||||
{{1, 1108}, {2, 652}, {3, 273}, {4, 572}, {5, 126}, {6, 449}}};
|
||||
const std::array<ConthistBonus, 6> conthist_bonuses = {
|
||||
{{1, 1157}, {2, 648}, {3, 288}, {4, 576}, {5, 140}, {6, 441}}};
|
||||
|
||||
for (const auto [i, weight] : conthist_bonuses)
|
||||
{
|
||||
@@ -1863,7 +1864,7 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
|
||||
if (ss->inCheck && i > 2)
|
||||
break;
|
||||
if (((ss - i)->currentMove).is_ok())
|
||||
(*(ss - i)->continuationHistory)[pc][to] << (bonus * weight / 1024) + 80 * (i < 2);
|
||||
(*(ss - i)->continuationHistory)[pc][to] << (bonus * weight / 1024) + 88 * (i < 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1876,10 +1877,10 @@ void update_quiet_histories(
|
||||
workerThread.mainHistory[us][move.from_to()] << bonus; // Untuned to prevent duplicate effort
|
||||
|
||||
if (ss->ply < LOW_PLY_HISTORY_SIZE)
|
||||
workerThread.lowPlyHistory[ss->ply][move.from_to()] << (bonus * 771 / 1024) + 40;
|
||||
workerThread.lowPlyHistory[ss->ply][move.from_to()] << (bonus * 741 / 1024) + 38;
|
||||
|
||||
update_continuation_histories(ss, pos.moved_piece(move), move.to_sq(),
|
||||
bonus * (bonus > 0 ? 979 : 842) / 1024);
|
||||
bonus * (bonus > 0 ? 995 : 915) / 1024);
|
||||
|
||||
int pIndex = pawn_history_index(pos);
|
||||
workerThread.pawnHistory[pIndex][pos.moved_piece(move)][move.to_sq()]
|
||||
|
||||
Reference in New Issue
Block a user