+ const int D = 324;
+ auto& entry = (*this)[c][from_to(m)];
+
+ assert(abs(v) <= D); // Consistency check for below formula
+
+ entry += v * 32 - entry * abs(v) / D;
+
+ assert(abs(entry) <= 32 * D);
+ }
+};
+
+/// PieceToHistory is like ButterflyHistory, but is based on PieceToBoards
+struct PieceToHistory : public PieceToBoards {
+
+ void update(Piece pc, Square to, int v) {
+
+ const int D = 936;
+ auto& entry = (*this)[pc][to];
+
+ assert(abs(v) <= D); // Consistency check for below formula
+
+ entry += v * 32 - entry * abs(v) / D;
+
+ assert(abs(entry) <= 32 * D);
+ }