X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.h;h=ef3be6c240f8d553b42c68756e48fa512b5bdf3d;hp=c19141820e3397804580a06fbc8b02df12e5e7a0;hb=ced29248c93de7fc5a4e284807f8f052006e647c;hpb=352bd6f5aa348e15909f50266fc5bdc003df35bf diff --git a/src/movepick.h b/src/movepick.h index c1914182..ef3be6c2 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -42,7 +42,11 @@ struct HistoryStats { Square from = from_sq(m); Square to = to_sq(m); - table[c][from][to] -= table[c][from][to] * abs(int(v)) / 324; + const int denom = 324; + + assert(abs(int(v)) <= denom); // Needed for stability. + + table[c][from][to] -= table[c][from][to] * abs(int(v)) / denom; table[c][from][to] += int(v) * 32; } @@ -62,10 +66,15 @@ struct Stats { const T* operator[](Piece pc) const { return table[pc]; } T* operator[](Piece pc) { return table[pc]; } void clear() { std::memset(table, 0, sizeof(table)); } + void fill(const Value& v) { std::fill(&table[0][0], &table[PIECE_NB-1][SQUARE_NB-1]+1, v); }; void update(Piece pc, Square to, Move m) { table[pc][to] = m; } void update(Piece pc, Square to, Value v) { - table[pc][to] -= table[pc][to] * abs(int(v)) / 936; + const int denom = 936; + + assert(abs(int(v)) <= denom); // Needed for stability. + + table[pc][to] -= table[pc][to] * abs(int(v)) / denom; table[pc][to] += int(v) * 32; }