]> git.sesse.net Git - stockfish/blobdiff - src/types.h
Prefer 0 to EmptyBoardBB
[stockfish] / src / types.h
index f8eab0c2711cad795a215b972df306221601aa7d..7040b5ad8fd8d333835143ea5cb96566eb4dd1fd 100644 (file)
@@ -46,9 +46,6 @@ typedef unsigned __int64 uint64_t;
 
 #endif
 
-#define Min(x, y) (((x) < (y)) ? (x) : (y))
-#define Max(x, y) (((x) < (y)) ? (y) : (x))
-
 ////
 //// Configuration
 ////
@@ -161,6 +158,24 @@ typedef uint64_t Bitboard;
 const int PLY_MAX = 100;
 const int PLY_MAX_PLUS_2 = PLY_MAX + 2;
 
+const Bitboard FileABB = 0x0101010101010101ULL;
+const Bitboard FileBBB = FileABB << 1;
+const Bitboard FileCBB = FileABB << 2;
+const Bitboard FileDBB = FileABB << 3;
+const Bitboard FileEBB = FileABB << 4;
+const Bitboard FileFBB = FileABB << 5;
+const Bitboard FileGBB = FileABB << 6;
+const Bitboard FileHBB = FileABB << 7;
+
+const Bitboard Rank1BB = 0xFF;
+const Bitboard Rank2BB = Rank1BB << (8 * 1);
+const Bitboard Rank3BB = Rank1BB << (8 * 2);
+const Bitboard Rank4BB = Rank1BB << (8 * 3);
+const Bitboard Rank5BB = Rank1BB << (8 * 4);
+const Bitboard Rank6BB = Rank1BB << (8 * 5);
+const Bitboard Rank7BB = Rank1BB << (8 * 6);
+const Bitboard Rank8BB = Rank1BB << (8 * 7);
+
 enum ValueType {
   VALUE_TYPE_NONE  = 0,
   VALUE_TYPE_UPPER = 1,
@@ -350,14 +365,6 @@ extern const Value PieceValueMidgame[17];
 extern const Value PieceValueEndgame[17];
 extern int SquareDistance[64][64];
 
-inline Value piece_value_midgame(Piece p) {
-  return PieceValueMidgame[p];
-}
-
-inline Value piece_value_endgame(Piece p) {
-  return PieceValueEndgame[p];
-}
-
 inline Value value_mate_in(int ply) {
   return VALUE_MATE - ply;
 }
@@ -382,11 +389,6 @@ inline Color flip(Color c) {
   return Color(c ^ 1);
 }
 
-inline char piece_type_to_char(PieceType pt) {
-  static const char ch[] = " PNBRQK";
-  return ch[pt];
-}
-
 inline Square make_square(File f, Rank r) {
   return Square((r << 3) | f);
 }
@@ -423,11 +425,11 @@ inline Rank relative_rank(Color c, Square s) {
   return relative_rank(c, rank_of(s));
 }
 
-inline SquareColor square_color(Square s) {
+inline SquareColor color_of(Square s) {
   return SquareColor(int(rank_of(s) + s) & 1);
 }
 
-inline bool opposite_color_squares(Square s1, Square s2) {
+inline bool opposite_colors(Square s1, Square s2) {
   int s = s1 ^ s2;
   return ((s >> 3) ^ s) & 1;
 }
@@ -444,6 +446,10 @@ inline int square_distance(Square s1, Square s2) {
   return SquareDistance[s1][s2];
 }
 
+inline char piece_type_to_char(PieceType pt) {
+  return " PNBRQK"[pt];
+}
+
 inline char file_to_char(File f) {
   return char(f - FILE_A + int('a'));
 }
@@ -454,7 +460,7 @@ inline char rank_to_char(Rank r) {
 
 inline const std::string square_to_string(Square s) {
   char ch[] = { file_to_char(file_of(s)), rank_to_char(rank_of(s)), 0 };
-  return std::string(ch);
+  return ch;
 }
 
 inline Square pawn_push(Color c) {