X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbitboard.h;h=b0e272338c0f536f95067a4f34747ba6e714b22f;hb=e7c1c8c1abd85a71fd8190e0c1af49214625904b;hp=440de1ea1ee0be74befddbac703a15d91b900bbf;hpb=09bef14c76e119103cc1a9404cbde7e249205deb;p=stockfish diff --git a/src/bitboard.h b/src/bitboard.h index 440de1ea..b0e27233 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -129,8 +129,8 @@ constexpr bool more_than_one(Bitboard b) { return b & (b - 1); } -inline bool opposite_colors(Square s1, Square s2) { - return bool(DarkSquares & s1) != bool(DarkSquares & s2); +constexpr bool opposite_colors(Square s1, Square s2) { + return (s1 + rank_of(s1) + s2 + rank_of(s2)) & 1; } @@ -154,7 +154,7 @@ inline Bitboard file_bb(Square s) { } -/// shift() moves a bitboard one step along direction D +/// shift() moves a bitboard one or two steps as specified by the direction D template constexpr Bitboard shift(Bitboard b) { @@ -199,8 +199,8 @@ inline Bitboard adjacent_files_bb(Square s) { /// If the given squares are not on a same file/rank/diagonal, return 0. inline Bitboard between_bb(Square s1, Square s2) { - return LineBB[s1][s2] & ( (AllSquares << (s1 + (s1 < s2))) - ^(AllSquares << (s2 + !(s1 < s2)))); + Bitboard b = LineBB[s1][s2] & ((AllSquares << s1) ^ (AllSquares << s2)); + return b & (b - 1); //exclude lsb }