]> git.sesse.net Git - stockfish/commitdiff
Retire enum SquareDelta
authorMarco Costalba <mcostalba@gmail.com>
Wed, 23 Feb 2011 09:03:30 +0000 (10:03 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 23 Feb 2011 17:41:35 +0000 (18:41 +0100)
Use Square instead. At the end is the same because we were
anyway foreseen operators on mixed terms (Square, SquareDelta).

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/evaluate.cpp
src/movegen.cpp
src/piece.h
src/square.h

index bc8d5c3d93664f9b0a543d9e990817a86802728c..bc05bfa070c7d9d4afd7dba717443eaa957208e6 100644 (file)
@@ -482,8 +482,7 @@ namespace {
 
   void init_between_bitboards() {
 
 
   void init_between_bitboards() {
 
-    Square s1, s2, s3;
-    SquareDelta d;
+    Square s1, s2, s3, d;
     int f, r;
 
     for (s1 = SQ_A1; s1 <= SQ_H8; s1++)
     int f, r;
 
     for (s1 = SQ_A1; s1 <= SQ_H8; s1++)
@@ -493,7 +492,7 @@ namespace {
                 f = file_distance(s1, s2);
                 r = rank_distance(s1, s2);
 
                 f = file_distance(s1, s2);
                 r = rank_distance(s1, s2);
 
-                d = SquareDelta(s2 - s1) / Max(f, r);
+                d = (s2 - s1) / Max(f, r);
 
                 for (s3 = s1 + d; s3 != s2; s3 += d)
                     set_bit(&(BetweenBB[s1][s2]), s3);
 
                 for (s3 = s1 + d; s3 != s2; s3 += d)
                     set_bit(&(BetweenBB[s1][s2]), s3);
index 680b8e0fb58d163598b45a184eb3814f9edc4d0a..657b0f49257d7eb4a6c8e7fd24f6434ae0596f74 100644 (file)
@@ -569,8 +569,7 @@ namespace {
             // problem, especially when that pawn is also blocked.
             if (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1))
             {
             // problem, especially when that pawn is also blocked.
             if (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1))
             {
-                SquareDelta d = pawn_push(Us)
-                   + (square_file(s) == FILE_A ? DELTA_E : DELTA_W);
+                Square d = pawn_push(Us) + (square_file(s) == FILE_A ? DELTA_E : DELTA_W);
                 if (pos.piece_on(s + d) == piece_of_color_and_type(Us, PAWN))
                 {
                     if (!pos.square_is_empty(s + d + pawn_push(Us)))
                 if (pos.piece_on(s + d) == piece_of_color_and_type(Us, PAWN))
                 {
                     if (!pos.square_is_empty(s + d + pawn_push(Us)))
index 6f932cd05de6befd53b89737c5e0aadae1cdb516..5107d1057df0889b3458294c7946bba33d85102d 100644 (file)
@@ -462,7 +462,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
 
 namespace {
 
 
 namespace {
 
-  template<SquareDelta Delta>
+  template<Square Delta>
   inline Bitboard move_pawns(Bitboard p) {
 
     return Delta == DELTA_N  ? p << 8 : Delta == DELTA_S  ? p >> 8 :
   inline Bitboard move_pawns(Bitboard p) {
 
     return Delta == DELTA_N  ? p << 8 : Delta == DELTA_S  ? p >> 8 :
@@ -470,7 +470,7 @@ namespace {
            Delta == DELTA_NW ? p << 7 : Delta == DELTA_SW ? p >> 9 : p;
   }
 
            Delta == DELTA_NW ? p << 7 : Delta == DELTA_SW ? p >> 9 : p;
   }
 
-  template<MoveType Type, SquareDelta Delta>
+  template<MoveType Type, Square Delta>
   inline MoveStack* generate_pawn_captures(MoveStack* mlist, Bitboard pawns, Bitboard target) {
 
     const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
   inline MoveStack* generate_pawn_captures(MoveStack* mlist, Bitboard pawns, Bitboard target) {
 
     const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
@@ -484,7 +484,7 @@ namespace {
     return mlist;
   }
 
     return mlist;
   }
 
-  template<Color Us, MoveType Type, SquareDelta Delta>
+  template<Color Us, MoveType Type, Square Delta>
   inline MoveStack* generate_promotions(const Position& pos, MoveStack* mlist, Bitboard pawnsOn7, Bitboard target) {
 
     const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
   inline MoveStack* generate_promotions(const Position& pos, MoveStack* mlist, Bitboard pawnsOn7, Bitboard target) {
 
     const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
@@ -527,12 +527,12 @@ namespace {
 
     // Calculate our parametrized parameters at compile time, named
     // according to the point of view of white side.
 
     // Calculate our parametrized parameters at compile time, named
     // according to the point of view of white side.
-    const Color       Them      = (Us == WHITE ? BLACK    : WHITE);
-    const Bitboard    TRank7BB  = (Us == WHITE ? Rank7BB  : Rank2BB);
-    const Bitboard    TRank3BB  = (Us == WHITE ? Rank3BB  : Rank6BB);
-    const SquareDelta TDELTA_N  = (Us == WHITE ? DELTA_N  : DELTA_S);
-    const SquareDelta TDELTA_NE = (Us == WHITE ? DELTA_NE : DELTA_SE);
-    const SquareDelta TDELTA_NW = (Us == WHITE ? DELTA_NW : DELTA_SW);
+    const Color    Them      = (Us == WHITE ? BLACK    : WHITE);
+    const Bitboard TRank7BB  = (Us == WHITE ? Rank7BB  : Rank2BB);
+    const Bitboard TRank3BB  = (Us == WHITE ? Rank3BB  : Rank6BB);
+    const Square   TDELTA_N  = (Us == WHITE ? DELTA_N  : DELTA_S);
+    const Square   TDELTA_NE = (Us == WHITE ? DELTA_NE : DELTA_SE);
+    const Square   TDELTA_NW = (Us == WHITE ? DELTA_NW : DELTA_SW);
 
     Square to;
     Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares;
 
     Square to;
     Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares;
index be77079a413876fdc0ad08c4856a1a38e1ae66c0..64c94082af826f5ae030fbec0da45f15f4a0d830 100644 (file)
@@ -88,7 +88,7 @@ inline Piece piece_of_color_and_type(Color c, PieceType pt) {
   return Piece((int(c) << 3) | int(pt));
 }
 
   return Piece((int(c) << 3) | int(pt));
 }
 
-inline SquareDelta pawn_push(Color c) {
+inline Square pawn_push(Color c) {
     return (c == WHITE ? DELTA_N : DELTA_S);
 }
 
     return (c == WHITE ? DELTA_N : DELTA_S);
 }
 
index fe0cc9684101b669487c0d97bd81c9a783b23aca..bc5221b6b74578d2030042a4a3ddd6e69adda001 100644 (file)
@@ -35,20 +35,12 @@ enum Square {
   SQ_A6, SQ_B6, SQ_C6, SQ_D6, SQ_E6, SQ_F6, SQ_G6, SQ_H6,
   SQ_A7, SQ_B7, SQ_C7, SQ_D7, SQ_E7, SQ_F7, SQ_G7, SQ_H7,
   SQ_A8, SQ_B8, SQ_C8, SQ_D8, SQ_E8, SQ_F8, SQ_G8, SQ_H8,
   SQ_A6, SQ_B6, SQ_C6, SQ_D6, SQ_E6, SQ_F6, SQ_G6, SQ_H6,
   SQ_A7, SQ_B7, SQ_C7, SQ_D7, SQ_E7, SQ_F7, SQ_G7, SQ_H7,
   SQ_A8, SQ_B8, SQ_C8, SQ_D8, SQ_E8, SQ_F8, SQ_G8, SQ_H8,
-  SQ_NONE
-};
-
-enum File {
-  FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
-};
-
-enum Rank {
-  RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
-};
-
-enum SquareDelta {
+  SQ_NONE,
 
 
-  DELTA_N = 8, DELTA_E = 1, DELTA_S = -8, DELTA_W = -1, DELTA_NONE = 0,
+  DELTA_N =  8,
+  DELTA_E =  1,
+  DELTA_S = -8,
+  DELTA_W = -1,
 
   DELTA_NN = DELTA_N + DELTA_N,
   DELTA_NE = DELTA_N + DELTA_E,
 
   DELTA_NN = DELTA_N + DELTA_N,
   DELTA_NE = DELTA_N + DELTA_E,
@@ -58,19 +50,21 @@ enum SquareDelta {
   DELTA_NW = DELTA_N + DELTA_W
 };
 
   DELTA_NW = DELTA_N + DELTA_W
 };
 
+enum File {
+  FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
+};
+
+enum Rank {
+  RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
+};
+
 ENABLE_OPERATORS_ON(Square)
 ENABLE_OPERATORS_ON(File)
 ENABLE_OPERATORS_ON(Rank)
 ENABLE_OPERATORS_ON(Square)
 ENABLE_OPERATORS_ON(File)
 ENABLE_OPERATORS_ON(Rank)
-ENABLE_OPERATORS_ON(SquareDelta)
 
 const int FlipMask = 56;
 const int FlopMask =  7;
 
 
 const int FlipMask = 56;
 const int FlopMask =  7;
 
-inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); }
-inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); }
-inline Square operator- (Square x, SquareDelta i) { return x - Square(i); }
-inline void operator-= (Square& x, SquareDelta i) { x = x - Square(i); }
-
 inline Square make_square(File f, Rank r) {
   return Square((int(r) << 3) | int(f));
 }
 inline Square make_square(File f, Rank r) {
   return Square((int(r) << 3) | int(f));
 }