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++)
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);
// 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)))
namespace {
- template<SquareDelta Delta>
+ template<Square Delta>
inline Bitboard move_pawns(Bitboard p) {
return Delta == DELTA_N ? p << 8 : Delta == DELTA_S ? p >> 8 :
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);
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);
// 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;
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);
}
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_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(SquareDelta)
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));
}