X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fhistory.cpp;h=22116412c863c4e0a5efadbed4abf61931eb7e2b;hp=3cda37061d6d55a201413736323d927b24514158;hb=87303d7ed307766b51908541512f9a209dc99032;hpb=78246035499e277a7099b73bb96ac1e115643d61 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; }