From: Marco Costalba Date: Wed, 28 Dec 2011 09:49:55 +0000 (+0100) Subject: Retire SquaresByColorBB[] and enum SquareColor X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=ad4739a6d45d9d37afe2414f432a07190fae9b83 Retire SquaresByColorBB[] and enum SquareColor Use same_color_squares() instead. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 0e035b15..d9a9daba 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -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(b); - SquaresByColorBB[DARK] = 0xAA55AA55AA55AA55ULL; - SquaresByColorBB[LIGHT] = ~SquaresByColorBB[DARK]; - for (Square s = SQ_A1; s <= SQ_H8; s++) { SetMaskBB[s] = 1ULL << s; diff --git a/src/bitboard.h b/src/bitboard.h index 83668278..9685b9d4 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -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. diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 5d8d7b99..ab10597b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -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; diff --git a/src/position.cpp b/src/position.cpp index f0bbff44..d14f0416 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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 << '|'; diff --git a/src/types.h b/src/types.h index f1627a96..b73eccba 100644 --- a/src/types.h +++ b/src/types.h @@ -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;