r++;
// Decrease/increase reduction for moves with a good/bad history (~30 Elo)
- r -= ss->statScore / 14884;
+ // If we are not in check use statScore, if we are in check
+ // use sum of main history and first continuation history with an offset
+ if (ss->inCheck)
+ r -= (thisThread->mainHistory[us][from_to(move)]
+ + (*contHist[0])[movedPiece][to_sq(move)] - 4333) / 16384;
+ else
+ r -= ss->statScore / 14884;
}
Depth d = std::clamp(newDepth - r, 1, newDepth);