1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-02 09:39:36 +00:00

Retire pieces_of_color_and_type()

It is used mainly in a bunch of inline oneliners
just below its definition. So substitute it with
the explicit definition and avoid information hiding.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-08-31 16:09:52 +02:00
parent cf71efc34b
commit 17c5119222
4 changed files with 18 additions and 22 deletions

View file

@ -930,7 +930,7 @@ namespace {
b3 |= (b2 & pos.pieces_of_color(them));
// There are no enemy pawns in the pawn's path
assert((b2 & pos.pieces_of_color_and_type(them, PAWN)) == EmptyBoardBB);
assert((b2 & pos.pieces_of_color(them) & pos.pieces_of_type(PAWN)) == EmptyBoardBB);
// Are any of the squares in the pawn's path attacked or occupied by the enemy?
if (b3 == EmptyBoardBB)

View file

@ -832,7 +832,7 @@ namespace {
MoveStack* generate_piece_checks(const Position& pos, MoveStack* mlist, Color us,
Bitboard dc, Square ksq) {
Bitboard target = pos.pieces_of_color_and_type(us, Piece);
Bitboard target = pos.pieces_of_color(us) & pos.pieces_of_type(Piece);
// Discovered checks
Bitboard b = target & dc;

View file

@ -1382,11 +1382,12 @@ int Position::see(Square from, Square to) const {
// Locate the least valuable attacker to the destination square
// and use it to initialize from square.
stmAttackers = attackers & pieces_of_color(us);
PieceType pt;
for (pt = PAWN; !(attackers & pieces_of_color_and_type(us, pt)); pt++)
for (pt = PAWN; !(stmAttackers & pieces_of_type(pt)); pt++)
assert(pt < KING);
from = first_1(attackers & pieces_of_color_and_type(us, pt));
from = first_1(stmAttackers & pieces_of_type(pt));
piece = piece_on(from);
}
@ -1633,7 +1634,7 @@ Value Position::compute_value() const {
for (Color c = WHITE; c <= BLACK; c++)
for (PieceType pt = PAWN; pt <= KING; pt++)
{
b = pieces_of_color_and_type(c, pt);
b = pieces_of_color(c) & pieces_of_type(pt);
while(b)
{
s = pop_1st_bit(&b);
@ -1659,7 +1660,7 @@ Value Position::compute_non_pawn_material(Color c) const {
for (PieceType pt = KNIGHT; pt <= QUEEN; pt++)
{
Bitboard b = pieces_of_color_and_type(c, pt);
Bitboard b = pieces_of_color(c) & pieces_of_type(pt);
while (b)
{
assert(piece_on(first_1(b)) == piece_of_color_and_type(c, pt));
@ -2011,7 +2012,7 @@ bool Position::is_ok(int* failedStep) const {
if (debugPieceCounts)
for (Color c = WHITE; c <= BLACK; c++)
for (PieceType pt = PAWN; pt <= KING; pt++)
if (pieceCount[c][pt] != count_1s(pieces_of_color_and_type(c, pt)))
if (pieceCount[c][pt] != count_1s(pieces_of_color(c) & pieces_of_type(pt)))
return false;
if (failedStep) (*failedStep)++;
@ -2021,7 +2022,7 @@ bool Position::is_ok(int* failedStep) const {
for(PieceType pt = PAWN; pt <= KING; pt++)
for(int i = 0; i < pieceCount[c][pt]; i++)
{
if (piece_on(piece_list(c, pt, i)) != piece_of_color_and_type(c, pt))
if (piece_on(piece_list(c, pt, i)) != (pieces_of_color(c) & pieces_of_type(pt)))
return false;
if (index[piece_list(c, pt, i)] != i)

View file

@ -133,7 +133,7 @@ public:
};
// Constructors
Position() {};
Position() {}
Position(const Position& pos);
Position(const std::string& fen);
@ -163,7 +163,6 @@ public:
Bitboard occupied_squares() const;
Bitboard pieces_of_color(Color c) const;
Bitboard pieces_of_type(PieceType pt) const;
Bitboard pieces_of_color_and_type(Color c, PieceType pt) const;
Bitboard pawns() const;
Bitboard knights() const;
Bitboard bishops() const;
@ -414,10 +413,6 @@ inline Bitboard Position::pieces_of_type(PieceType pt) const {
return byTypeBB[pt];
}
inline Bitboard Position::pieces_of_color_and_type(Color c, PieceType pt) const {
return pieces_of_color(c) & pieces_of_type(pt);
}
inline Bitboard Position::pawns() const {
return pieces_of_type(PAWN);
}
@ -455,35 +450,35 @@ inline Bitboard Position::sliders() const {
}
inline Bitboard Position::pawns(Color c) const {
return pieces_of_color_and_type(c, PAWN);
return pieces_of_color(c) & pieces_of_type(PAWN);
}
inline Bitboard Position::knights(Color c) const {
return pieces_of_color_and_type(c, KNIGHT);
return pieces_of_color(c) & pieces_of_type(KNIGHT);
}
inline Bitboard Position::bishops(Color c) const {
return pieces_of_color_and_type(c, BISHOP);
return pieces_of_color(c) & pieces_of_type(BISHOP);
}
inline Bitboard Position::rooks(Color c) const {
return pieces_of_color_and_type(c, ROOK);
return pieces_of_color(c) & pieces_of_type(ROOK);
}
inline Bitboard Position::queens(Color c) const {
return pieces_of_color_and_type(c, QUEEN);
return pieces_of_color(c) & pieces_of_type(QUEEN);
}
inline Bitboard Position::kings(Color c) const {
return pieces_of_color_and_type(c, KING);
return pieces_of_color(c) & pieces_of_type(KING);
}
inline Bitboard Position::rooks_and_queens(Color c) const {
return rooks_and_queens() & pieces_of_color(c);
return pieces_of_color(c) & rooks_and_queens();
}
inline Bitboard Position::bishops_and_queens(Color c) const {
return bishops_and_queens() & pieces_of_color(c);
return pieces_of_color(c) & bishops_and_queens();
}
inline int Position::piece_count(Color c, PieceType pt) const {