Thread* bestThread = this;
- if (int(Options["MultiPV"]) == 1 &&
- !Limits.depth &&
- !(Skill(Options["Skill Level"]).enabled() || int(Options["UCI_LimitStrength"])) &&
- rootMoves[0].pv[0] != MOVE_NONE)
+ if ( int(Options["MultiPV"]) == 1
+ && !Limits.depth
+ && !(Skill(Options["Skill Level"]).enabled() || int(Options["UCI_LimitStrength"]))
+ && rootMoves[0].pv[0] != MOVE_NONE)
bestThread = Threads.get_best_thread();
bestPreviousScore = bestThread->rootMoves[0].score;
Key posKey;
Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth;
- Value bestValue, value, ttValue, eval, maxValue;
+ Value bestValue, value, ttValue, eval, maxValue, probcutBeta;
bool ttHit, ttPv, formerPv, givesCheck, improving, didLMR, priorCapture;
bool captureOrPromotion, doFullDepthSearch, moveCountPruning,
ttCapture, singularQuietLMR;
ttPv = PvNode || (ttHit && tte->is_pv());
formerPv = ttPv && !PvNode;
- if (ttPv && depth > 12 && ss->ply - 1 < MAX_LPH && !priorCapture && is_ok((ss-1)->currentMove))
+ if ( ttPv
+ && depth > 12
+ && ss->ply - 1 < MAX_LPH
+ && !priorCapture
+ && is_ok((ss-1)->currentMove))
thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
}
}
+ probcutBeta = beta + 176 - 49 * improving;
+
// Step 10. ProbCut (~10 Elo)
// If we have a good enough capture and a reduced search returns a value
// much above beta, we can (almost) safely prune the previous move.
if ( !PvNode
&& depth > 4
- && abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
+ && abs(beta) < VALUE_TB_WIN_IN_MAX_PLY
+ && !( ttHit
+ && tte->depth() >= depth - 3
+ && ttValue != VALUE_NONE
+ && ttValue < probcutBeta))
{
- Value raisedBeta = beta + 176 - 49 * improving;
- assert(raisedBeta < VALUE_INFINITE);
- MovePicker mp(pos, ttMove, raisedBeta - ss->staticEval, &captureHistory);
+ if ( ttHit
+ && tte->depth() >= depth - 3
+ && ttValue != VALUE_NONE
+ && ttValue >= probcutBeta
+ && ttMove
+ && pos.capture_or_promotion(ttMove))
+ return probcutBeta;
+
+ assert(probcutBeta < VALUE_INFINITE);
+ MovePicker mp(pos, ttMove, probcutBeta - ss->staticEval, &captureHistory);
int probCutCount = 0;
while ( (move = mp.next_move()) != MOVE_NONE
- && probCutCount < 2 + 2 * cutNode
- && !( move == ttMove
- && tte->depth() >= depth - 4
- && ttValue < raisedBeta))
+ && probCutCount < 2 + 2 * cutNode)
if (move != excludedMove && pos.legal(move))
{
assert(pos.capture_or_promotion(move));
pos.do_move(move, st);
// Perform a preliminary qsearch to verify that the move holds
- value = -qsearch<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1);
+ value = -qsearch<NonPV>(pos, ss+1, -probcutBeta, -probcutBeta+1);
// If the qsearch held, perform the regular search
- if (value >= raisedBeta)
- value = -search<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1, depth - 4, !cutNode);
+ if (value >= probcutBeta)
+ value = -search<NonPV>(pos, ss+1, -probcutBeta, -probcutBeta+1, depth - 4, !cutNode);
pos.undo_move(move);
- if (value >= raisedBeta)
+ if (value >= probcutBeta)
+ {
+ if ( !(ttHit
+ && tte->depth() >= depth - 3
+ && ttValue != VALUE_NONE))
+ tte->save(posKey, value_to_tt(value, ss->ply), ttPv,
+ BOUND_LOWER,
+ depth - 3, move, ss->staticEval);
return value;
+ }
}
}
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
// then that move is singular and should be extended. To verify this we do
// a reduced search on all the other moves but the ttMove and if the
- // result is lower than ttValue minus a margin then we will extend the ttMove.
+ // result is lower than ttValue minus a margin, then we will extend the ttMove.
if ( depth >= 6
&& move == ttMove
&& !rootNode
if (type_of(move) == CASTLING)
extension = 1;
- // Late irreversible move extension
- if ( move == ttMove
- && pos.rule50_count() > 80
- && (captureOrPromotion || type_of(movedPiece) == PAWN))
- extension = 2;
-
// Add extension to new depth
newDepth += extension;
{
Depth r = reduction(improving, depth, moveCount);
+ // Decrease reduction at non-check cut nodes for second move at low depths
+ if ( cutNode
+ && depth <= 10
+ && moveCount <= 2
+ && !ss->inCheck)
+ r--;
+
// Decrease reduction if the ttHit running average is large
if (thisThread->ttHitAverage > 473 * TtHitAverageResolution * TtHitAverageWindow / 1024)
r--;
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
- // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
- // be generated.
+ // queen and checking knight promotions, and other checks(only if depth >= DEPTH_QS_CHECKS)
+ // will be generated.
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
&thisThread->captureHistory,
contHist,
<< " multipv " << i + 1
<< " score " << UCI::value(v);
+ if (Options["UCI_ShowWDL"])
+ ss << UCI::wdl(v, pos.game_ply());
+
if (!tb && i == pvIdx)
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");