X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftypes.h;h=1514c8c162914b497a918e31a138c1b51a825c4b;hp=595290dfeaf87a854e36c789249758b78bd2c036;hb=c5de4080dba8e9b3248f06bd6c168c22e9fbfd92;hpb=d8f683760c9eb6d2c4714ec83e717dd2143de55c diff --git a/src/types.h b/src/types.h index 595290df..1514c8c1 100644 --- a/src/types.h +++ b/src/types.h @@ -185,9 +185,9 @@ enum Value : int { PawnValueMg = 188, PawnValueEg = 248, KnightValueMg = 753, KnightValueEg = 832, - BishopValueMg = 826, BishopValueEg = 897, + BishopValueMg = 814, BishopValueEg = 890, RookValueMg = 1285, RookValueEg = 1371, - QueenValueMg = 2513, QueenValueEg = 2650, + QueenValueMg = 2513, QueenValueEg = 2648, MidgameLimit = 15258, EndgameLimit = 3915 }; @@ -285,19 +285,19 @@ inline Value mg_value(Score s) { #define ENABLE_BASE_OPERATORS_ON(T) \ inline T operator+(T d1, T d2) { return T(int(d1) + int(d2)); } \ inline T operator-(T d1, T d2) { return T(int(d1) - int(d2)); } \ -inline T operator*(int i, T d) { return T(i * int(d)); } \ -inline T operator*(T d, int i) { return T(int(d) * i); } \ inline T operator-(T d) { return T(-int(d)); } \ inline T& operator+=(T& d1, T d2) { return d1 = d1 + d2; } \ inline T& operator-=(T& d1, T d2) { return d1 = d1 - d2; } \ -inline T& operator*=(T& d, int i) { return d = T(int(d) * i); } #define ENABLE_FULL_OPERATORS_ON(T) \ ENABLE_BASE_OPERATORS_ON(T) \ +inline T operator*(int i, T d) { return T(i * int(d)); } \ +inline T operator*(T d, int i) { return T(int(d) * i); } \ inline T& operator++(T& d) { return d = T(int(d) + 1); } \ inline T& operator--(T& d) { return d = T(int(d) - 1); } \ inline T operator/(T d, int i) { return T(int(d) / i); } \ inline int operator/(T d1, T d2) { return int(d1) / int(d2); } \ +inline T& operator*=(T& d, int i) { return d = T(int(d) * i); } \ inline T& operator/=(T& d, int i) { return d = T(int(d) / i); } ENABLE_FULL_OPERATORS_ON(Value) @@ -329,6 +329,17 @@ inline Score operator/(Score s, int i) { return make_score(mg_value(s) / i, eg_value(s) / i); } +/// Multiplication of a Score by an integer. We check for overflow in debug mode. +inline Score operator*(Score s, int i) { + Score result = Score(int(s) * i); + + assert(eg_value(result) == (i * eg_value(s))); + assert(mg_value(result) == (i * mg_value(s))); + assert((i == 0) || (result / i) == s ); + + return result; +} + inline Color operator~(Color c) { return Color(c ^ BLACK); // Toggle color }