// History and stats update bonus, based on depth
int stat_bonus(Depth d) {
// History and stats update bonus, based on depth
int stat_bonus(Depth d) {
ss->currentMove = MOVE_NULL;
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
ss->currentMove = MOVE_NULL;
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
// Step 9. ProbCut (~10 Elo)
// If we have a good enough capture and a reduced search returns a value
// Step 9. ProbCut (~10 Elo)
// If we have a good enough capture and a reduced search returns a value
&& (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
&& (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
+ (*contHist[3])[movedPiece][to_sq(move)]
// use sum of main history and first continuation history with an offset
if (ss->inCheck)
r -= (thisThread->mainHistory[us][from_to(move)]
// use sum of main history and first continuation history with an offset
if (ss->inCheck)
r -= (thisThread->mainHistory[us][from_to(move)]
- bonus2 = bestValue > beta + PawnValueMg ? bonus1 // larger bonus
- : stat_bonus(depth); // smaller bonus
+ bonus2 = bestValue > beta + PawnValueMg ? bonus1 // larger bonus
+ : std::min(bonus1, stat_bonus(depth)); // smaller bonus