]> git.sesse.net Git - stockfish/commitdiff
Use int16_t in History values
authorlucasart <lucas.braesch@gmail.com>
Wed, 9 Aug 2017 11:35:05 +0000 (19:35 +0800)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 17 Aug 2017 07:32:44 +0000 (00:32 -0700)
Reduces memory footprint by ~1.2MB (per thread).

Strong pressure: small but mesurable gain
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 258430 W: 46977 L: 45943 D: 165510

Low pressure: no regression
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 73542 W: 13058 L: 13026 D: 47458

Strong pressure + LTC: elo gain confirmed
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 31489 W: 4532 L: 4295 D: 22662

Tested for crashing on overflow and after 70K
games at STC we have only 4 time losses,
possible candidate for an overflow.

No functional change.

src/movepick.h

index afd573ea459badabd1aa208b5d6dd498d49d455b..41a83604e09e99b768360ebb66b382d7510918a8 100644 (file)
@@ -28,7 +28,7 @@
 #include "types.h"
 
 /// StatBoards is a generic 2-dimensional array used to store various statistics
 #include "types.h"
 
 /// StatBoards is a generic 2-dimensional array used to store various statistics
-template<int Size1, int Size2, typename T = int>
+template<int Size1, int Size2, typename T = int16_t>
 struct StatBoards : public std::array<std::array<T, Size2>, Size1> {
 
   void fill(const T& v) {
 struct StatBoards : public std::array<std::array<T, Size2>, 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
     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;
 
 
     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
     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;
 
 
     entry += bonus * 32 - entry * abs(bonus) / D;