From: protonspring Date: Sat, 8 Dec 2018 17:57:25 +0000 (-0700) Subject: simplify opposite_colors X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=fefc0c67898ecf5101a4632846564874b78345c4;ds=sidebyside simplify opposite_colors --- diff --git a/src/bitboard.h b/src/bitboard.h index c6dbc647..f8440a23 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -135,6 +135,10 @@ 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); +} + /// rank_bb() and file_bb() return a bitboard representing all the squares on /// the given file or rank. diff --git a/src/types.h b/src/types.h index 3b5afecf..c4c2752c 100644 --- a/src/types.h +++ b/src/types.h @@ -413,11 +413,6 @@ constexpr Rank relative_rank(Color c, Square s) { return relative_rank(c, rank_of(s)); } -inline bool opposite_colors(Square s1, Square s2) { - int s = int(s1) ^ int(s2); - return ((s >> 3) ^ s) & 1; -} - constexpr Direction pawn_push(Color c) { return c == WHITE ? NORTH : SOUTH; }