- if (!captureOrPromotion)
- {
- // Increase reduction if ttMove is a capture (~3 Elo)
- if (ttCapture)
- r++;
-
- // Increase reduction for cut nodes (~3 Elo)
- if (cutNode)
- r += 2;
-
- 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)]
- - 4923;
-
- // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
- if (!ss->inCheck)
- r -= ss->statScore / 14721;
- }
+ // Decrease reduction for PvNodes based on depth
+ if (PvNode)
+ r -= 1 + 15 / ( 3 + depth );
+
+ // Increase reduction if next ply has a lot of fail high else reset count to 0
+ if ((ss+1)->cutoffCnt > 3 && !PvNode)
+ r++;
+
+ 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)]
+ - 4334;
+
+ // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
+ r -= ss->statScore / 15914;
+
+ // In general we want to cap the LMR depth search at newDepth. But if reductions
+ // are really negative and movecount is low, we allow this move to be searched
+ // deeper than the first move (this may lead to hidden double extensions).
+ int deeper = r >= -1 ? 0
+ : moveCount <= 4 ? 2
+ : PvNode || cutNode ? 1
+ : 0;