X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=7c4a55f00f4a98b9d864b5c924d3a837951d476c;hp=a8c0afbcd3cde49532b1ae95b13481a4b0a809f1;hb=6fb0a1bc4050dd9b15e9c163c46c60f25c48137d;hpb=8631b08d9704dac256462f6b5b885a4d8b0a9165;ds=sidebyside diff --git a/src/bitboard.h b/src/bitboard.h index a8c0afbc..7c4a55f0 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -112,17 +112,12 @@ 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 dist(file_of(s1), file_of(s2)); -} +template inline int distance(T x, T y) { return x < y ? y - x : x - y; } +template<> inline int distance(Square x, Square y) { return SquareDistance[x][y]; } -inline int rank_distance(Square s1, Square s2) { - return dist(rank_of(s1), rank_of(s2)); -} +template inline int distance(T2 x, T2 y); +template<> inline int distance(Square x, Square y) { return distance(file_of(x), file_of(y)); } +template<> inline int distance(Square x, Square y) { return distance(rank_of(x), rank_of(y)); } /// shift_bb() moves bitboard one step along direction Delta. Mainly for pawns.