mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 11:39:15 +00:00
Retire enum SquareDelta
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>
This commit is contained in:
parent
aa40d0a917
commit
deb212cb05
5 changed files with 26 additions and 34 deletions
|
@ -482,8 +482,7 @@ namespace {
|
|||
|
||||
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++)
|
||||
|
@ -493,7 +492,7 @@ namespace {
|
|||
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);
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
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)))
|
||||
|
|
|
@ -462,7 +462,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
|
|||
|
||||
namespace {
|
||||
|
||||
template<SquareDelta Delta>
|
||||
template<Square Delta>
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -484,7 +484,7 @@ namespace {
|
|||
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);
|
||||
|
@ -527,12 +527,12 @@ namespace {
|
|||
|
||||
// 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;
|
||||
|
|
|
@ -88,7 +88,7 @@ inline Piece piece_of_color_and_type(Color c, PieceType 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);
|
||||
}
|
||||
|
||||
|
|
32
src/square.h
32
src/square.h
|
@ -35,7 +35,19 @@ 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_NONE
|
||||
SQ_NONE,
|
||||
|
||||
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_SE = DELTA_S + DELTA_E,
|
||||
DELTA_SS = DELTA_S + DELTA_S,
|
||||
DELTA_SW = DELTA_S + DELTA_W,
|
||||
DELTA_NW = DELTA_N + DELTA_W
|
||||
};
|
||||
|
||||
enum File {
|
||||
|
@ -46,31 +58,13 @@ enum Rank {
|
|||
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
|
||||
};
|
||||
|
||||
enum SquareDelta {
|
||||
|
||||
DELTA_N = 8, DELTA_E = 1, DELTA_S = -8, DELTA_W = -1, DELTA_NONE = 0,
|
||||
|
||||
DELTA_NN = DELTA_N + DELTA_N,
|
||||
DELTA_NE = DELTA_N + DELTA_E,
|
||||
DELTA_SE = DELTA_S + DELTA_E,
|
||||
DELTA_SS = DELTA_S + DELTA_S,
|
||||
DELTA_SW = DELTA_S + DELTA_W,
|
||||
DELTA_NW = DELTA_N + DELTA_W
|
||||
};
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue