diff --git a/src/search.cpp b/src/search.cpp index 74e0c1233..028f61cce 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1873,6 +1873,10 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) { static constexpr std::array conthist_bonuses = { {{1, 1106}, {2, 705}, {3, 316}, {4, 572}, {5, 126}, {6, 427}}}; + // Multipliers for positive history consistency + constexpr int CMHCMultipliers[] = {87, 94, 106, 118, 114, 128, 128}; + int positiveCount = 0; + for (const auto [i, weight] : conthist_bonuses) { // Only update the first 2 continuation histories if we are in check @@ -1880,7 +1884,14 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) { break; if (((ss - i)->currentMove).is_ok()) - (*(ss - i)->continuationHistory)[pc][to] << (bonus * weight / 1024) + 82 * (i < 2); + { + auto& historyEntry = (*(ss - i)->continuationHistory)[pc][to]; + if (historyEntry > 0) + positiveCount++; + + int multiplier = CMHCMultipliers[positiveCount]; + historyEntry << (bonus * weight * multiplier / 131072) + 82 * (i < 2); + } } }