X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftypes.h;h=6af0368720313d4c8cb7260566a92726f5256daa;hp=934f884e8fb5b740e3b5f1a40dfcd57560c68b87;hb=7756344d5d2b93970e7cd423f8cbf6fb1da11b74;hpb=61f44ce57864f866de5d26a3402a9ad135e17c6d diff --git a/src/types.h b/src/types.h index 934f884e..6af03687 100644 --- a/src/types.h +++ b/src/types.h @@ -345,6 +345,11 @@ inline Score operator*(Score s, int i) { return result; } +/// Multiplication of a Score by an boolean +inline Score operator*(Score s, bool b) { + return Score(int(s) * int(b)); +} + constexpr Color operator~(Color c) { return Color(c ^ BLACK); // Toggle color } @@ -361,6 +366,10 @@ constexpr Piece operator~(Piece pc) { return Piece(pc ^ 8); // Swap color of piece B_KNIGHT -> W_KNIGHT } +inline File map_to_queenside(File f) { + return std::min(f, File(FILE_H - f)); // Map files ABCDEFGH to files ABCDDCBA +} + constexpr CastlingRights operator&(Color c, CastlingRights cr) { return CastlingRights((c == WHITE ? WHITE_CASTLING : BLACK_CASTLING) & cr); }