- if (captureOrPromotion)
- {
- // Increase reduction for non-checking captures likely to be bad
- if ( !givesCheck
- && ss->staticEval + PieceValue[EG][pos.captured_piece()] + 210 * depth <= alpha)
- r++;
- }
- else
- {
- // Increase reduction if ttMove is a capture (~5 Elo)
- if (ttCapture)
- r++;
-
- // Increase reduction at root if failing high
- r += rootNode ? thisThread->failedHighCnt * thisThread->failedHighCnt * moveCount / 512 : 0;
-
- // Increase reduction for cut nodes (~10 Elo)
- if (cutNode)
- r += 2;
-
- // Decrease reduction for moves that escape a capture. Filter out
- // castling moves, because they are coded as "king captures rook" and
- // hence break reverse_move() (~2 Elo)
- else if ( type_of(move) == NORMAL
- && !pos.see_ge(reverse_move(move)))
- r -= 2 + ss->ttPv - (type_of(movedPiece) == PAWN);
-
- ss->statScore = thisThread->mainHistory[us][from_to(move)]
- + (*contHist[0])[movedPiece][to_sq(move)]
- + (*contHist[1])[movedPiece][to_sq(move)]
- + (*contHist[3])[movedPiece][to_sq(move)]
- - 4741;
-
- // Decrease/increase reduction by comparing opponent's stat score (~10 Elo)
- if (ss->statScore >= -89 && (ss-1)->statScore < -116)
- r--;
-
- else if ((ss-1)->statScore >= -112 && ss->statScore < -100)
- r++;
-
- // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
- // If we are not in check use statScore, but if we are in check we use
- // the 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)] - 3833) / 16384;
- else
- r -= ss->statScore / 14790;
- }