X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fhistory.cpp;h=22116412c863c4e0a5efadbed4abf61931eb7e2b;hp=949ba316420d8dc5351e412e32f1e23b414b261a;hb=c2df60048e8fbbca5dff66b98e4e0f4bf1413821;hpb=2161d8b0b3df48db419a25e3bc626c21eb062d75 diff --git a/src/history.cpp b/src/history.cpp index 949ba316..22116412 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -61,7 +61,7 @@ void History::success(Piece p, Square to, Depth d) { if (history[p][to] >= HistoryMax) for (int i = 0; i < 16; i++) for (int j = 0; j < 64; j++) - history[i][j] /= 4; + history[i][j] /= 2; } @@ -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; }