From fefc0c67898ecf5101a4632846564874b78345c4 Mon Sep 17 00:00:00 2001 From: protonspring Date: Sat, 8 Dec 2018 10:57:25 -0700 Subject: [PATCH] simplify opposite_colors --- src/bitboard.h | 4 ++++ src/types.h | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) 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; } -- 2.39.2