+ // Bonus for prior countermove that caused the fail low
+ else if (!bestMove)
+ {
+ if (is_ok((ss - 2)->currentMove) && is_ok((ss - 1)->currentMove) && !pos.captured_piece_type() && !inCheck && depth>=3*ONE_PLY)
+ {
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
+ Square prevSq = to_sq((ss - 1)->currentMove);
+ Square prevPrevSq = to_sq((ss - 2)->currentMove);
+ HistoryStats& flMoveCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
+ flMoveCmh.updateCMH(pos.piece_on(prevSq), prevSq, bonus);
+ }
+ }
+