Use same_color_squares() instead.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Bitboard SetMaskBB[65];
Bitboard ClearMaskBB[65];
Bitboard SetMaskBB[65];
Bitboard ClearMaskBB[65];
-Bitboard SquaresByColorBB[2];
Bitboard FileBB[8];
Bitboard RankBB[8];
Bitboard NeighboringFilesBB[8];
Bitboard FileBB[8];
Bitboard RankBB[8];
Bitboard NeighboringFilesBB[8];
for (Bitboard b = 0; b < 256; b++)
BitCount8Bit[b] = (uint8_t)count_1s<CNT32_MAX15>(b);
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;
for (Square s = SQ_A1; s <= SQ_H8; s++)
{
SetMaskBB[s] = 1ULL << s;
-extern Bitboard SquaresByColorBB[2];
extern Bitboard FileBB[8];
extern Bitboard NeighboringFilesBB[8];
extern Bitboard ThisAndNeighboringFilesBB[8];
extern Bitboard FileBB[8];
extern Bitboard NeighboringFilesBB[8];
extern Bitboard ThisAndNeighboringFilesBB[8];
+/// 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.
/// 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.
if (bonus && bit_is_set(ei.attackedBy[Us][PAWN], s))
{
if ( !pos.pieces(KNIGHT, Them)
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;
bonus += bonus + bonus / 2;
else
bonus += bonus / 2;
Piece piece = piece_on(sq);
char c = (color_of(piece) == BLACK ? '=' : ' ');
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 << '|';
piece++; // Index the dot
cout << c << PieceToChar[piece] << c << '|';
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
};
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,
enum ScaleFactor {
SCALE_FACTOR_DRAW = 0,
SCALE_FACTOR_NORMAL = 64,
return relative_rank(c, rank_of(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;
inline bool opposite_colors(Square s1, Square s2) {
int s = s1 ^ s2;
return ((s >> 3) ^ s) & 1;