mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-23 05:07:14 +00:00
Merge commit 'a2a7edf4c8fa145667135bf1bc7f4f67016f7608' into cluster
This is the last commit before there are more conflicts.
This commit is contained in:
+25
-20
@@ -162,7 +162,7 @@ void Search::Worker::start_searching() {
|
||||
}
|
||||
|
||||
main_manager()->tm.init(limits, rootPos.side_to_move(), rootPos.game_ply(), options,
|
||||
main_manager()->originalPly);
|
||||
main_manager()->originalTimeAdjust);
|
||||
tt.new_search();
|
||||
|
||||
if (rootMoves.empty())
|
||||
@@ -598,11 +598,12 @@ Value Search::Worker::search(
|
||||
Key posKey;
|
||||
Move ttMove, move, excludedMove, bestMove;
|
||||
Depth extension, newDepth;
|
||||
Value bestValue, value, ttValue, eval, maxValue, probCutBeta;
|
||||
Value bestValue, value, ttValue, eval, maxValue, probCutBeta, singularValue;
|
||||
bool givesCheck, improving, priorCapture, opponentWorsening;
|
||||
bool capture, moveCountPruning, ttCapture;
|
||||
Piece movedPiece;
|
||||
int moveCount, captureCount, quietCount;
|
||||
Bound singularBound;
|
||||
|
||||
// Step 1. Initialize node
|
||||
Worker* thisThread = this;
|
||||
@@ -667,7 +668,7 @@ Value Search::Worker::search(
|
||||
ss->ttPv = PvNode || (ss->ttHit && tte->is_pv());
|
||||
|
||||
// At non-PV nodes we check for an early TT cutoff
|
||||
if (!PvNode && !excludedMove && tte->depth() > depth
|
||||
if (!PvNode && !excludedMove && tte->depth() > depth - (ttValue <= beta)
|
||||
&& ttValue != VALUE_NONE // Possible in case of TT access race or if !ttHit
|
||||
&& (tte->bound() & (ttValue >= beta ? BOUND_LOWER : BOUND_UPPER)))
|
||||
{
|
||||
@@ -973,6 +974,8 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
value = bestValue;
|
||||
moveCountPruning = false;
|
||||
singularValue = VALUE_INFINITE;
|
||||
singularBound = BOUND_NONE;
|
||||
|
||||
// Step 13. Loop through all pseudo-legal moves until no moves remain
|
||||
// or a beta cutoff occurs.
|
||||
@@ -1022,7 +1025,9 @@ moves_loop: // When in check, search starts here
|
||||
if (!rootNode && pos.non_pawn_material(us) && bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
|
||||
{
|
||||
// Skip quiet moves if movecount exceeds our FutilityMoveCount threshold (~8 Elo)
|
||||
moveCountPruning = moveCount >= futility_move_count(improving, depth);
|
||||
moveCountPruning =
|
||||
moveCount >= futility_move_count(improving, depth)
|
||||
- (singularBound == BOUND_UPPER && singularValue < alpha - 50);
|
||||
|
||||
// Reduced depth of the next LMR search
|
||||
int lmrDepth = newDepth - r;
|
||||
@@ -1108,19 +1113,18 @@ moves_loop: // When in check, search starts here
|
||||
Depth singularDepth = newDepth / 2;
|
||||
|
||||
ss->excludedMove = move;
|
||||
value =
|
||||
value = singularValue =
|
||||
search<NonPV>(pos, ss, singularBeta - 1, singularBeta, singularDepth, cutNode);
|
||||
singularBound = singularValue >= singularBeta ? BOUND_LOWER : BOUND_UPPER;
|
||||
ss->excludedMove = Move::none();
|
||||
|
||||
if (value < singularBeta)
|
||||
{
|
||||
int doubleMargin = 304 * PvNode - 203 * !ttCapture;
|
||||
int tripleMargin = 117 + 259 * PvNode - 296 * !ttCapture + 97 * ss->ttPv;
|
||||
int quadMargin = 486 + 343 * PvNode - 273 * !ttCapture + 232 * ss->ttPv;
|
||||
|
||||
extension = 1 + (value < singularBeta - doubleMargin)
|
||||
+ (value < singularBeta - tripleMargin)
|
||||
+ (value < singularBeta - quadMargin);
|
||||
+ (value < singularBeta - tripleMargin);
|
||||
|
||||
depth += ((!PvNode) && (depth < 16));
|
||||
}
|
||||
@@ -1201,17 +1205,17 @@ moves_loop: // When in check, search starts here
|
||||
if ((ss + 1)->cutoffCnt > 3)
|
||||
r++;
|
||||
|
||||
// Set reduction to 0 for first picked move (ttMove) (~2 Elo)
|
||||
// Nullifies all previous reduction adjustments to ttMove and leaves only history to do them
|
||||
// For first picked move (ttMove) reduce reduction
|
||||
// but never allow it to go below 0 (~3 Elo)
|
||||
else if (move == ttMove)
|
||||
r = 0;
|
||||
r = std::max(0, r - 2);
|
||||
|
||||
ss->statScore = 2 * thisThread->mainHistory[us][move.from_to()]
|
||||
+ (*contHist[0])[movedPiece][move.to_sq()]
|
||||
+ (*contHist[1])[movedPiece][move.to_sq()] - 5169;
|
||||
|
||||
// Decrease/increase reduction for moves with a good/bad history (~8 Elo)
|
||||
r -= ss->statScore / (12219 - std::min(depth, 13) * 120);
|
||||
r -= ss->statScore / 11049;
|
||||
|
||||
// Step 17. Late moves reduction / extension (LMR, ~117 Elo)
|
||||
if (depth >= 2 && moveCount > 1 + rootNode)
|
||||
@@ -1341,7 +1345,7 @@ moves_loop: // When in check, search starts here
|
||||
|
||||
if (value >= beta)
|
||||
{
|
||||
ss->cutoffCnt += 1 + !ttMove;
|
||||
ss->cutoffCnt += 1 + !ttMove - (extension >= 2);
|
||||
assert(value >= beta); // Fail high
|
||||
break;
|
||||
}
|
||||
@@ -1391,18 +1395,19 @@ 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 < -14144)
|
||||
+ ((ss - 1)->moveCount > 9) + (!ss->inCheck && bestValue <= ss->staticEval - 115)
|
||||
+ (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 81);
|
||||
int bonus = (116 * (depth > 5) + 115 * (PvNode || cutNode)
|
||||
+ 186 * ((ss - 1)->statScore < -14144) + 121 * ((ss - 1)->moveCount > 9)
|
||||
+ 64 * (!ss->inCheck && bestValue <= ss->staticEval - 115)
|
||||
+ 137 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 81));
|
||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
|
||||
stat_bonus(depth) * bonus);
|
||||
stat_bonus(depth) * bonus / 100);
|
||||
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()]
|
||||
<< stat_bonus(depth) * bonus / 2;
|
||||
<< stat_bonus(depth) * bonus / 200;
|
||||
|
||||
|
||||
if (type_of(pos.piece_on(prevSq)) != PAWN && ((ss - 1)->currentMove).type_of() != PROMOTION)
|
||||
thisThread->pawnHistory[pawn_structure_index(pos)][pos.piece_on(prevSq)][prevSq]
|
||||
<< stat_bonus(depth) * bonus * 4;
|
||||
<< stat_bonus(depth) * bonus / 25;
|
||||
}
|
||||
|
||||
if (PvNode)
|
||||
@@ -1536,7 +1541,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||
to_corrected_static_eval(unadjustedStaticEval, *thisThread, pos);
|
||||
|
||||
// ttValue can be used as a better position evaluation (~13 Elo)
|
||||
if (ttValue != VALUE_NONE
|
||||
if (std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY
|
||||
&& (tte->bound() & (ttValue > bestValue ? BOUND_LOWER : BOUND_UPPER)))
|
||||
bestValue = ttValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user