]> git.sesse.net Git - stockfish/blobdiff - src/bitboard.h
Determine opposite colors mathematically
[stockfish] / src / bitboard.h
index 440de1ea1ee0be74befddbac703a15d91b900bbf..d11b7e732b66227515d83c54647daed57a5937c3 100644 (file)
@@ -129,8 +129,8 @@ 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);
+constexpr bool opposite_colors(Square s1, Square s2) {
+  return (s1 + rank_of(s1) + s2 + rank_of(s2)) & 1;
 }
 
 
 }