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)
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;
// 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);
}
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);
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));
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)++;
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)
};
// Constructors
- Position() {};
+ Position() {}
Position(const Position& pos);
Position(const std::string& fen);
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;
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);
}
}
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 {