]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Introduce a new counter move history penalty
[stockfish] / src / search.cpp
index cae89c6a929014ce9364c60a444f188a396341c7..b0e2c950fe7354c784cd14689ab7c3cbb7bed6b4 100644 (file)
@@ -585,7 +585,7 @@ namespace {
     ss->ttMove = ttMove = RootNode ? RootMoves[PVIdx].pv[0] : ttHit ? tte->move() : MOVE_NONE;
     ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
 
-    // At non-PV nodes we check for a fail high/low. We don't probe at PV nodes
+    // At non-PV nodes we check for a fail high/low. We don't prune at PV nodes
     if (  !PvNode
         && ttHit
         && tte->depth() >= depth
@@ -1437,8 +1437,16 @@ moves_loop: // When in check and at SpNode search starts from here
 
     if (is_ok((ss-2)->currentMove) && (ss-1)->currentMove == (ss-1)->ttMove)
     {
+        Value bonus2 = Value(((depth+1) / ONE_PLY) * ((depth+1) / ONE_PLY));
+
         Square prevPrevSq = to_sq((ss-2)->currentMove);
         Followupmoves.update(pos.piece_on(prevPrevSq), prevPrevSq, move);
+
+        Square prevMoveSq = to_sq((ss-1)->currentMove);
+        Piece prevMovePiece = pos.piece_on(prevMoveSq);
+
+        HistoryStats& cmh2 = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
+        cmh2.update(prevMovePiece, prevMoveSq, -bonus2);
     }
   }