Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
- Square bishopSquare = pos.bishop_list(strongerSide, 0);
+ Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0);
if(square_color(bishopSquare) == BLACK) {
winnerKSq = flop_square(winnerKSq);
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
- wpsq = pos.pawn_list(WHITE, 0);
+ wpsq = pos.piece_list(WHITE, PAWN, 0);
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
- wpsq = flip_square(pos.pawn_list(BLACK, 0));
+ wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
stm = opposite_color(pos.side_to_move());
}
int tempo = (pos.side_to_move() == strongerSide);
wksq = pos.king_square(strongerSide);
- wrsq = pos.rook_list(strongerSide, 0);
+ wrsq = pos.piece_list(strongerSide, ROOK, 0);
bksq = pos.king_square(weakerSide);
- bpsq = pos.pawn_list(weakerSide, 0);
+ bpsq = pos.piece_list(weakerSide, PAWN, 0);
if(strongerSide == BLACK) {
wksq = flip_square(wksq);
assert(pos.knight_count(weakerSide) == 1);
Square defendingKSq = pos.king_square(weakerSide);
- Square nSq = pos.knight_list(weakerSide, 0);
+ Square nSq = pos.piece_list(weakerSide, KNIGHT, 0);
Value result = Value(10) + mate_table(defendingKSq) +
krkn_king_knight_distance_penalty(square_distance(defendingKSq, nSq));
// be detected even when the weaker side has some pawns.
Bitboard pawns = pos.pawns(strongerSide);
- File pawnFile = square_file(pos.pawn_list(strongerSide, 0));
+ File pawnFile = square_file(pos.piece_list(strongerSide, PAWN, 0));
if((pawnFile == FILE_A || pawnFile == FILE_H) &&
(pawns & ~file_bb(pawnFile)) == EmptyBoardBB) {
// All pawns are on a single rook file.
- Square bishopSq = pos.bishop_list(strongerSide, 0);
+ Square bishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square queeningSq =
relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
(pos.rooks(weakerSide) & relative_rank_bb(weakerSide, RANK_3)) &&
(pos.pawns(weakerSide) & relative_rank_bb(weakerSide, RANK_2)) &&
(pos.piece_attacks<KING>(kingSq) & pos.pawns(weakerSide))) {
- Square rsq = pos.rook_list(weakerSide, 0);
+ Square rsq = pos.piece_list(weakerSide, ROOK, 0);
if(pos.pawn_attacks(strongerSide, rsq) & pos.pawns(weakerSide))
return ScaleFactor(0);
}
assert(pos.pawn_count(weakerSide) == 0);
Square wksq = pos.king_square(strongerSide);
- Square wrsq = pos.rook_list(strongerSide, 0);
- Square wpsq = pos.pawn_list(strongerSide, 0);
+ Square wrsq = pos.piece_list(strongerSide, ROOK, 0);
+ Square wpsq = pos.piece_list(strongerSide, PAWN, 0);
Square bksq = pos.king_square(weakerSide);
- Square brsq = pos.rook_list(weakerSide, 0);
+ Square brsq = pos.piece_list(weakerSide, ROOK, 0);
// Orient the board in such a way that the stronger side is white, and the
// pawn is on the left half of the board:
assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
assert(pos.pawn_count(weakerSide) == 1);
- Square wpsq1 = pos.pawn_list(strongerSide, 0);
- Square wpsq2 = pos.pawn_list(strongerSide, 1);
+ Square wpsq1 = pos.piece_list(strongerSide, PAWN, 0);
+ Square wpsq2 = pos.piece_list(strongerSide, PAWN, 1);
Square bksq = pos.king_square(weakerSide);
// Does the stronger side have a passed pawn?
assert(pos.bishop_count(weakerSide) == 1);
assert(pos.pawn_count(weakerSide) == 0);
- Square pawnSq = pos.pawn_list(strongerSide, 0);
- Square strongerBishopSq = pos.bishop_list(strongerSide, 0);
- Square weakerBishopSq = pos.bishop_list(weakerSide, 0);
+ Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
+ Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
+ Square weakerBishopSq = pos.piece_list(weakerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide);
// Case 1: Defending king blocks the pawn, and cannot be driven away.
assert(pos.knight_count(weakerSide) == 1);
assert(pos.pawn_count(weakerSide) == 0);
- Square pawnSq = pos.pawn_list(strongerSide, 0);
- Square strongerBishopSq = pos.bishop_list(strongerSide, 0);
+ Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
+ Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide);
if(square_file(weakerKingSq) == square_file(pawnSq)
assert(pos.non_pawn_material(weakerSide) == Value(0));
assert(pos.pawn_count(weakerSide) == 0);
- Square pawnSq = pos.pawn_list(strongerSide, 0);
+ Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
Square weakerKingSq = pos.king_square(weakerSide);
if(pawnSq == relative_square(strongerSide, SQ_A7) &&
if(strongerSide == WHITE) {
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
- wpsq = pos.pawn_list(WHITE, 0);
+ wpsq = pos.piece_list(WHITE, PAWN, 0);
stm = pos.side_to_move();
}
else {
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
- wpsq = flip_square(pos.pawn_list(BLACK, 0));
+ wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
stm = opposite_color(pos.side_to_move());
}
{
// Knights
for (int i = 0; i < pos.knight_count(c); i++)
- evaluate_knight(pos, pos.knight_list(c, i), c, ei);
+ evaluate_knight(pos, pos.piece_list(c, KNIGHT, i), c, ei);
// Bishops
for (int i = 0; i < pos.bishop_count(c); i++)
- evaluate_bishop(pos, pos.bishop_list(c, i), c, ei);
+ evaluate_bishop(pos, pos.piece_list(c, BISHOP, i), c, ei);
// Rooks
for (int i = 0; i < pos.rook_count(c); i++)
- evaluate_rook(pos, pos.rook_list(c, i), c, ei);
+ evaluate_rook(pos, pos.piece_list(c, ROOK, i), c, ei);
// Queens
for(int i = 0; i < pos.queen_count(c); i++)
- evaluate_queen(pos, pos.queen_list(c, i), c, ei);
+ evaluate_queen(pos, pos.piece_list(c, QUEEN, i), c, ei);
// Special pattern: trapped bishops on a7/h7/a2/h2
Bitboard b = pos.bishops(c) & MaskA7H7[c];
// is an X-ray attack through the queen.
for (int i = 0; i < p.queen_count(them); i++)
{
- from = p.queen_list(them, i);
+ from = p.piece_list(them, QUEEN, i);
if ( bit_is_set(p.piece_attacks<QUEEN>(from), to)
&& !bit_is_set(p.pinned_pieces(them), from)
&& !(rook_attacks_bb(to, occ & clear_mask_bb(from)) & p.rooks_and_queens(us))
// Checking pieces
Bitboard checkers() const;
- // Piece lists:
+ // Piece lists
Square piece_list(Color c, PieceType pt, int index) const;
- Square pawn_list(Color c, int index) const;
- Square knight_list(Color c, int index) const;
- Square bishop_list(Color c, int index) const;
- Square rook_list(Color c, int index) const;
- Square queen_list(Color c, int index) const;
// Attack information for a given square
bool square_is_attacked(Square s, Color c) const;
return pieceList[c][pt][index];
}
-inline Square Position::pawn_list(Color c, int index) const {
- return piece_list(c, PAWN, index);
-}
-
-inline Square Position::knight_list(Color c, int index) const {
- return piece_list(c, KNIGHT, index);
-}
-
-inline Square Position::bishop_list(Color c, int index) const {
- return piece_list(c, BISHOP, index);
-}
-
-inline Square Position::rook_list(Color c, int index) const {
- return piece_list(c, ROOK, index);
-}
-
-inline Square Position::queen_list(Color c, int index) const {
- return piece_list(c, QUEEN, index);
-}
-
inline Square Position::ep_square() const {
return epSquare;
}
inline bool Position::opposite_colored_bishops() const {
return bishop_count(WHITE) == 1
- && bishop_count(BLACK) == 1
- && square_color(bishop_list(WHITE, 0)) != square_color(bishop_list(BLACK, 0));
+ && bishop_count(BLACK) == 1
+ && square_color(piece_list(WHITE, BISHOP, 0)) != square_color(piece_list(BLACK, BISHOP, 0));
}
inline bool Position::has_pawn_on_7th(Color c) const {