]> git.sesse.net Git - stockfish/commitdiff
Retire SquaresByColorBB[] and enum SquareColor
authorMarco Costalba <mcostalba@gmail.com>
Wed, 28 Dec 2011 09:49:55 +0000 (10:49 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 28 Dec 2011 09:57:08 +0000 (10:57 +0100)
Use same_color_squares() instead.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/bitboard.h
src/evaluate.cpp
src/position.cpp
src/types.h

index 0e035b15f37b6867d1601431eae1f5c98298e90c..d9a9daba8b854d4ebdcdb2c3701ff2e38cdb386d 100644 (file)
@@ -38,7 +38,6 @@ int BShifts[64];
 Bitboard SetMaskBB[65];
 Bitboard ClearMaskBB[65];
 
-Bitboard SquaresByColorBB[2];
 Bitboard FileBB[8];
 Bitboard RankBB[8];
 Bitboard NeighboringFilesBB[8];
@@ -157,9 +156,6 @@ void bitboards_init() {
   for (Bitboard b = 0; b < 256; b++)
       BitCount8Bit[b] = (uint8_t)count_1s<CNT32_MAX15>(b);
 
-  SquaresByColorBB[DARK]  =  0xAA55AA55AA55AA55ULL;
-  SquaresByColorBB[LIGHT] = ~SquaresByColorBB[DARK];
-
   for (Square s = SQ_A1; s <= SQ_H8; s++)
   {
       SetMaskBB[s] = 1ULL << s;
index 8366827804dea8a87afa2aaae09aa73ffb9ea79a..9685b9d429a24846dbc30acecf3adbc31680422c 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "types.h"
 
-extern Bitboard SquaresByColorBB[2];
 extern Bitboard FileBB[8];
 extern Bitboard NeighboringFilesBB[8];
 extern Bitboard ThisAndNeighboringFilesBB[8];
@@ -226,6 +225,15 @@ inline bool squares_aligned(Square s1, Square s2, Square s3) {
 }
 
 
+/// same_color_squares() returns a bitboard representing all squares with
+/// the same color of the given square.
+
+inline Bitboard same_color_squares(Square s) {
+  return bit_is_set(0xAA55AA55AA55AA55ULL, s) ?  0xAA55AA55AA55AA55ULL
+                                              : ~0xAA55AA55AA55AA55ULL;
+}
+
+
 /// first_1() finds the least significant nonzero bit in a nonzero bitboard.
 /// pop_1st_bit() finds and clears the least significant nonzero bit in a
 /// nonzero bitboard.
index 5d8d7b9902ec77fa1e1078e26b7e44725d44da7a..ab10597b6fe69c70241bdada24fdd4596404498c 100644 (file)
@@ -463,7 +463,7 @@ namespace {
     if (bonus && bit_is_set(ei.attackedBy[Us][PAWN], s))
     {
         if (   !pos.pieces(KNIGHT, Them)
-            && !(SquaresByColorBB[color_of(s)] & pos.pieces(BISHOP, Them)))
+            && !(same_color_squares(s) & pos.pieces(BISHOP, Them)))
             bonus += bonus + bonus / 2;
         else
             bonus += bonus / 2;
index f0bbff449427eaa09509645876532ebfe5b45f8d..d14f04169b95b1a2751711756dea4e730fc7f098 100644 (file)
@@ -338,7 +338,7 @@ void Position::print(Move move) const {
           Piece piece = piece_on(sq);
           char c = (color_of(piece) == BLACK ? '=' : ' ');
 
-          if (piece == NO_PIECE && color_of(sq) == DARK)
+          if (piece == NO_PIECE && !opposite_colors(sq, SQ_A1))
               piece++; // Index the dot
 
           cout << c << PieceToChar[piece] << c << '|';
index f1627a961168403c568872e64abff409e9307065..b73eccbac09c89a015de01cfe2afcb873be51152 100644 (file)
@@ -283,10 +283,6 @@ enum Rank {
   RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
 };
 
-enum SquareColor {
-  DARK, LIGHT
-};
-
 enum ScaleFactor {
   SCALE_FACTOR_DRAW   = 0,
   SCALE_FACTOR_NORMAL = 64,
@@ -452,10 +448,6 @@ inline Rank relative_rank(Color c, Square s) {
   return relative_rank(c, rank_of(s));
 }
 
-inline SquareColor color_of(Square s) {
-  return SquareColor(int(rank_of(s) + s) & 1);
-}
-
 inline bool opposite_colors(Square s1, Square s2) {
   int s = s1 ^ s2;
   return ((s >> 3) ^ s) & 1;