]> git.sesse.net Git - stockfish/blobdiff - src/types.h
Move game phase constants to enum Value
[stockfish] / src / types.h
index f041e29db5102c7defa5ad8a250d20b2309d76c4..02b651dd9b124df4fc66d4e8c15dddd36afa2d76 100644 (file)
 #  include <nmmintrin.h> // Intel header for _mm_popcnt_u64() intrinsic
 #endif
 
+#if defined(USE_PEXT)
+#  include <immintrin.h> // Header for _pext_u64() intrinsic
+#else
+#  define _pext_u64(b, m) (0)
+#endif
+
 #  if !defined(NO_PREFETCH) && (defined(__INTEL_COMPILER) || defined(_MSC_VER))
 #   include <xmmintrin.h> // Intel and Microsoft header for _mm_prefetch()
 #  endif
@@ -79,6 +85,12 @@ const bool HasPopCnt = true;
 const bool HasPopCnt = false;
 #endif
 
+#ifdef USE_PEXT
+const bool HasPext = true;
+#else
+const bool HasPext = false;
+#endif
+
 #ifdef IS_64BIT
 const bool Is64Bit = true;
 #else
@@ -124,20 +136,20 @@ enum CastlingSide {
   KING_SIDE, QUEEN_SIDE, CASTLING_SIDE_NB = 2
 };
 
-enum CastlingFlag {  // Defined as in PolyGlot book hash key
+enum CastlingRight {  // Defined as in PolyGlot book hash key
   NO_CASTLING,
   WHITE_OO,
   WHITE_OOO   = WHITE_OO << 1,
   BLACK_OO    = WHITE_OO << 2,
   BLACK_OOO   = WHITE_OO << 3,
   ANY_CASTLING = WHITE_OO | WHITE_OOO | BLACK_OO | BLACK_OOO,
-  CASTLING_FLAG_NB = 16
+  CASTLING_RIGHT_NB = 16
 };
 
 template<Color C, CastlingSide S> struct MakeCastling {
-  static const CastlingFlag
-  flag = C == WHITE ? S == QUEEN_SIDE ? WHITE_OOO : WHITE_OO
-                    : S == QUEEN_SIDE ? BLACK_OOO : BLACK_OO;
+  static const CastlingRight
+  right = C == WHITE ? S == QUEEN_SIDE ? WHITE_OOO : WHITE_OO
+                     : S == QUEEN_SIDE ? BLACK_OOO : BLACK_OO;
 };
 
 enum Phase {
@@ -165,9 +177,9 @@ enum Value {
   VALUE_ZERO      = 0,
   VALUE_DRAW      = 0,
   VALUE_KNOWN_WIN = 10000,
-  VALUE_MATE      = 30000,
-  VALUE_INFINITE  = 30001,
-  VALUE_NONE      = 30002,
+  VALUE_MATE      = 32000,
+  VALUE_INFINITE  = 32001,
+  VALUE_NONE      = 32002,
 
   VALUE_MATE_IN_MAX_PLY  =  VALUE_MATE - MAX_PLY,
   VALUE_MATED_IN_MAX_PLY = -VALUE_MATE + MAX_PLY,
@@ -179,7 +191,9 @@ enum Value {
   KnightValueMg = 817,   KnightValueEg = 846,
   BishopValueMg = 836,   BishopValueEg = 857,
   RookValueMg   = 1270,  RookValueEg   = 1278,
-  QueenValueMg  = 2521,  QueenValueEg  = 2558
+  QueenValueMg  = 2521,  QueenValueEg  = 2558,
+
+  MidgameLimit  = 15581, EndgameLimit  = 3998
 };
 
 enum PieceType {
@@ -322,11 +336,11 @@ extern Value PieceValue[PHASE_NB][PIECE_NB];
 
 struct ExtMove {
   Move move;
-  int score;
+  Value value;
 };
 
 inline bool operator<(const ExtMove& f, const ExtMove& s) {
-  return f.score < s.score;
+  return f.value < s.value;
 }
 
 inline Color operator~(Color c) {
@@ -337,12 +351,8 @@ inline Square operator~(Square s) {
   return Square(s ^ SQ_A8); // Vertical flip SQ_A1 -> SQ_A8
 }
 
-inline Square operator|(File f, Rank r) {
-  return Square((r << 3) | f);
-}
-
-inline CastlingFlag operator|(Color c, CastlingSide s) {
-  return CastlingFlag(WHITE_OO << ((s == QUEEN_SIDE) + 2 * c));
+inline CastlingRight operator|(Color c, CastlingSide s) {
+  return CastlingRight(WHITE_OO << ((s == QUEEN_SIDE) + 2 * c));
 }
 
 inline Value mate_in(int ply) {
@@ -353,17 +363,21 @@ inline Value mated_in(int ply) {
   return -VALUE_MATE + ply;
 }
 
+inline Square make_square(File f, Rank r) {
+  return Square((r << 3) | f);
+}
+
 inline Piece make_piece(Color c, PieceType pt) {
   return Piece((c << 3) | pt);
 }
 
-inline PieceType type_of(Piece p)  {
-  return PieceType(p & 7);
+inline PieceType type_of(Piece pc)  {
+  return PieceType(pc & 7);
 }
 
-inline Color color_of(Piece p) {
-  assert(p != NO_PIECE);
-  return Color(p >> 3);
+inline Color color_of(Piece pc) {
+  assert(pc != NO_PIECE);
+  return Color(pc >> 3);
 }
 
 inline bool is_ok(Square s) {