Skip to content

Commit 8cff486

Browse files
committed
Move SquareDistance[] to bitboard.cpp
No functional change.
1 parent 908d988 commit 8cff486

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/bitboard.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
8080
extern Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB];
8181
extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
8282

83+
extern int SquareDistance[SQUARE_NB][SQUARE_NB];
84+
8385
const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL;
8486

8587
/// Overloads of bitwise operators between a Bitboard and a Square for testing
@@ -105,13 +107,22 @@ inline Bitboard operator^(Bitboard b, Square s) {
105107
return b ^ SquareBB[s];
106108
}
107109

108-
109-
/// more_than_one() returns true if in 'b' there is more than one bit set
110-
111110
inline bool more_than_one(Bitboard b) {
112111
return b & (b - 1);
113112
}
114113

114+
inline int square_distance(Square s1, Square s2) {
115+
return SquareDistance[s1][s2];
116+
}
117+
118+
inline int file_distance(Square s1, Square s2) {
119+
return abs(file_of(s1) - file_of(s2));
120+
}
121+
122+
inline int rank_distance(Square s1, Square s2) {
123+
return abs(rank_of(s1) - rank_of(s2));
124+
}
125+
115126

116127
/// shift_bb() moves bitboard one step along direction Delta. Mainly for pawns.
117128

src/types.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ inline Score operator/(Score s, int i) {
310310
#undef ENABLE_SAFE_OPERATORS_ON
311311

312312
extern Value PieceValue[PHASE_NB][PIECE_NB];
313-
extern int SquareDistance[SQUARE_NB][SQUARE_NB];
314313

315314
struct MoveStack {
316315
Move move;
@@ -391,18 +390,6 @@ inline bool opposite_colors(Square s1, Square s2) {
391390
return ((s >> 3) ^ s) & 1;
392391
}
393392

394-
inline int file_distance(Square s1, Square s2) {
395-
return abs(file_of(s1) - file_of(s2));
396-
}
397-
398-
inline int rank_distance(Square s1, Square s2) {
399-
return abs(rank_of(s1) - rank_of(s2));
400-
}
401-
402-
inline int square_distance(Square s1, Square s2) {
403-
return SquareDistance[s1][s2];
404-
}
405-
406393
inline char file_to_char(File f, bool tolower = true) {
407394
return char(f - FILE_A + (tolower ? 'a' : 'A'));
408395
}

0 commit comments

Comments
 (0)