]> git.sesse.net Git - stockfish/commitdiff
simplify opposite_colors
authorprotonspring <mike@whiteley.org>
Sat, 8 Dec 2018 17:57:25 +0000 (10:57 -0700)
committerStéphane Nicolet <Stephane.Nicolet@u-paris2.fr>
Sun, 9 Dec 2018 11:59:57 +0000 (12:59 +0100)
src/bitboard.h
src/types.h

index c6dbc647b093dfe1c8d5d425554a76161138adeb..f8440a23a1aaf3f71635c672200786573d26b2b7 100644 (file)
@@ -135,6 +135,10 @@ constexpr bool more_than_one(Bitboard b) {
   return b & (b - 1);
 }
 
   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.
 
 /// rank_bb() and file_bb() return a bitboard representing all the squares on
 /// the given file or rank.
 
index 3b5afecf335f55d2aeb54c43bfc71532a3919fb6..c4c2752c8e553961a2fbc70140ee7dea4523e22f 100644 (file)
@@ -413,11 +413,6 @@ constexpr Rank relative_rank(Color c, Square s) {
   return relative_rank(c, rank_of(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;
 }
 constexpr Direction pawn_push(Color c) {
   return c == WHITE ? NORTH : SOUTH;
 }