X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.h;h=41a83604e09e99b768360ebb66b382d7510918a8;hp=afd573ea459badabd1aa208b5d6dd498d49d455b;hb=ae6a4ebf1f44cb05e96f8f33342ec281b41b0cc0;hpb=232c50fed0b80a0f39322a925575f760648ae0a5;ds=sidebyside diff --git a/src/movepick.h b/src/movepick.h index afd573ea..41a83604 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -28,7 +28,7 @@ #include "types.h" /// StatBoards is a generic 2-dimensional array used to store various statistics -template +template struct StatBoards : public std::array, Size1> { void fill(const T& v) { @@ -55,6 +55,10 @@ struct ButterflyHistory : public ButterflyBoards { auto& entry = (*this)[c][from_to(m)]; assert(abs(bonus) <= D); // Consistency check for below formula + assert([&]{ + int v = entry + bonus * 32 - entry * abs(bonus) / D; + return INT16_MIN < v && v < INT16_MAX; + }()); entry += bonus * 32 - entry * abs(bonus) / D; @@ -71,6 +75,10 @@ struct PieceToHistory : public PieceToBoards { auto& entry = (*this)[pc][to]; assert(abs(bonus) <= D); // Consistency check for below formula + assert([&]{ + int v = entry + bonus * 32 - entry * abs(bonus) / D; + return INT16_MIN < v && v < INT16_MAX; + }()); entry += bonus * 32 - entry * abs(bonus) / D;