From 14f059072af34bc21b71ae7fc550f03b4a075b3b Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 25 Jul 2010 11:44:03 +0100 Subject: [PATCH] Introduce enum SquareColor Square and piece colors are two different things, so use different types to avoid misunderstandings. Suggested by Tord. No functional change. Signed-off-by: Marco Costalba --- src/bitboard.cpp | 5 ++++- src/bitboard.h | 3 --- src/color.h | 5 +++++ src/square.h | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 063204c5..0c38e182 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -163,7 +163,10 @@ const int RShift[64] = { #endif // defined(IS_64BIT) -const Bitboard SquaresByColorBB[2] = { BlackSquaresBB, WhiteSquaresBB }; +const Bitboard LightSquaresBB = 0x55AA55AA55AA55AAULL; +const Bitboard DarkSquaresBB = 0xAA55AA55AA55AA55ULL; + +const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, LightSquaresBB }; const Bitboard FileBB[8] = { FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB diff --git a/src/bitboard.h b/src/bitboard.h index 9d061186..4236d073 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -38,9 +38,6 @@ const Bitboard EmptyBoardBB = 0ULL; -const Bitboard WhiteSquaresBB = 0x55AA55AA55AA55AAULL; -const Bitboard BlackSquaresBB = 0xAA55AA55AA55AA55ULL; - const Bitboard FileABB = 0x0101010101010101ULL; const Bitboard FileBBB = 0x0202020202020202ULL; const Bitboard FileCBB = 0x0404040404040404ULL; diff --git a/src/color.h b/src/color.h index 50901ef3..72a8bbc9 100644 --- a/src/color.h +++ b/src/color.h @@ -32,6 +32,11 @@ enum Color { COLOR_NONE }; +enum SquareColor { + DARK, + LIGHT +}; + //// //// Inline functions diff --git a/src/square.h b/src/square.h index d35d72bf..e4eab2ac 100644 --- a/src/square.h +++ b/src/square.h @@ -135,8 +135,8 @@ inline Rank relative_rank(Color c, Square s) { return square_rank(relative_square(c, s)); } -inline Color square_color(Square s) { - return Color((int(square_file(s)) + int(square_rank(s))) & 1); +inline SquareColor square_color(Square s) { + return SquareColor((int(square_file(s)) + int(square_rank(s))) & 1); } inline bool same_color_squares(Square s1, Square s2) { -- 2.39.2