X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=033964b75b3d9c657e997d5e9b9b566284303172;hp=6094c343f45236772abe34b7a2775641e3dec405;hb=8cff4862a65bdbf156609fea14f47ea4bdf42df3;hpb=908d98820b9f055d3089cc947f6901a2d6fe0d81 diff --git a/src/bitboard.h b/src/bitboard.h index 6094c343..033964b7 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -80,6 +80,8 @@ extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; extern Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB]; extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB]; +extern int SquareDistance[SQUARE_NB][SQUARE_NB]; + const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL; /// Overloads of bitwise operators between a Bitboard and a Square for testing @@ -105,13 +107,22 @@ inline Bitboard operator^(Bitboard b, Square s) { return b ^ SquareBB[s]; } - -/// more_than_one() returns true if in 'b' there is more than one bit set - inline bool more_than_one(Bitboard b) { return b & (b - 1); } +inline int square_distance(Square s1, Square s2) { + return SquareDistance[s1][s2]; +} + +inline int file_distance(Square s1, Square s2) { + return abs(file_of(s1) - file_of(s2)); +} + +inline int rank_distance(Square s1, Square s2) { + return abs(rank_of(s1) - rank_of(s2)); +} + /// shift_bb() moves bitboard one step along direction Delta. Mainly for pawns.