X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fhistory.cpp;fp=src%2Fhistory.cpp;h=22116412c863c4e0a5efadbed4abf61931eb7e2b;hp=3cda37061d6d55a201413736323d927b24514158;hb=942c18ef6620967921049ba24f25e08d710c947e;hpb=007285be2da7b77916d74f092e07de73bd1655ed diff --git a/src/history.cpp b/src/history.cpp index 3cda3706..22116412 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -75,8 +75,12 @@ void History::failure(Piece p, Square to, Depth d) { assert(square_is_ok(to)); history[p][to] -= int(d) * int(d); - if (history[p][to] < 0) - history[p][to] = 0; + + // Prevent history underflow + if (history[p][to] <= -HistoryMax) + for (int i = 0; i < 16; i++) + for (int j = 0; j < 64; j++) + history[i][j] /= 2; }