mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 08:13:08 +00:00
Retire SquaresByColorBB[] and enum SquareColor
Use same_color_squares() instead. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
a695ed65a8
commit
ad4739a6d4
5 changed files with 11 additions and 15 deletions
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 << '|';
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue