]> git.sesse.net Git - stockfish/commitdiff
Introduce enum SquareColor
authorMarco Costalba <mcostalba@gmail.com>
Sun, 25 Jul 2010 10:44:03 +0000 (11:44 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 25 Jul 2010 10:49:58 +0000 (11:49 +0100)
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 <mcostalba@gmail.com>
src/bitboard.cpp
src/bitboard.h
src/color.h
src/square.h

index 063204c5020f7ec2f54a5104ee705a618068fc4b..0c38e182ba3633f5c6040f3f810d34de74657a6f 100644 (file)
@@ -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
index 9d0611867a4990ecf4f5e37ec48d39c4f8ef14b5..4236d07348d1dfcf97f11f4f681c04ea7fd38385 100644 (file)
@@ -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;
index 50901ef30c3d1c52b99f6eef37d51819b1be487b..72a8bbc9af443ed756bd967c27c175f71b5735e1 100644 (file)
@@ -32,6 +32,11 @@ enum Color {
   COLOR_NONE
 };
 
+enum SquareColor {
+  DARK,
+  LIGHT
+};
+
 
 ////
 //// Inline functions
index d35d72bfd5b21311f1b2be9b79d05c597016d76f..e4eab2ac2bad85b6d54717bb41cbc6cf9e86c16e 100644 (file)
@@ -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) {