No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
- Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0);
+ Square bishopSquare = pos.piece_list(strongerSide, BISHOP)[0];
// kbnk_mate_table() tries to drive toward corners A1 or H8,
// if we have a bishop that cannot reach the above squares we
// kbnk_mate_table() tries to drive toward corners A1 or H8,
// if we have a bishop that cannot reach the above squares we
{
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
{
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
- wpsq = pos.piece_list(WHITE, PAWN, 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));
stm = pos.side_to_move();
}
else
{
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
- wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
+ wpsq = flip_square(pos.piece_list(BLACK, PAWN)[0]);
stm = opposite_color(pos.side_to_move());
}
stm = opposite_color(pos.side_to_move());
}
int tempo = (pos.side_to_move() == strongerSide);
wksq = pos.king_square(strongerSide);
int tempo = (pos.side_to_move() == strongerSide);
wksq = pos.king_square(strongerSide);
- wrsq = pos.piece_list(strongerSide, ROOK, 0);
+ wrsq = pos.piece_list(strongerSide, ROOK)[0];
bksq = pos.king_square(weakerSide);
bksq = pos.king_square(weakerSide);
- bpsq = pos.piece_list(weakerSide, PAWN, 0);
+ bpsq = pos.piece_list(weakerSide, PAWN)[0];
if (strongerSide == BLACK)
{
if (strongerSide == BLACK)
{
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
Square defendingKSq = pos.king_square(weakerSide);
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
Square defendingKSq = pos.king_square(weakerSide);
- Square nSq = pos.piece_list(weakerSide, KNIGHT, 0);
+ Square nSq = pos.piece_list(weakerSide, KNIGHT)[0];
int d = square_distance(defendingKSq, nSq);
Value result = Value(10)
int d = square_distance(defendingKSq, nSq);
Value result = Value(10)
Value result = BishopValueEndgame;
Square wksq = pos.king_square(strongerSide);
Square bksq = pos.king_square(weakerSide);
Value result = BishopValueEndgame;
Square wksq = pos.king_square(strongerSide);
Square bksq = pos.king_square(weakerSide);
- Square nsq = pos.piece_list(weakerSide, KNIGHT, 0);
+ Square nsq = pos.piece_list(weakerSide, KNIGHT)[0];
// Bonus for attacking king close to defending king
result += Value(DistanceBonus[square_distance(wksq, bksq)]);
// Bonus for attacking king close to defending king
result += Value(DistanceBonus[square_distance(wksq, bksq)]);
// be detected even when the weaker side has some pawns.
Bitboard pawns = pos.pieces(PAWN, strongerSide);
// be detected even when the weaker side has some pawns.
Bitboard pawns = pos.pieces(PAWN, strongerSide);
- File pawnFile = square_file(pos.piece_list(strongerSide, PAWN, 0));
+ File pawnFile = square_file(pos.piece_list(strongerSide, PAWN)[0]);
// All pawns are on a single rook file ?
if ( (pawnFile == FILE_A || pawnFile == FILE_H)
&& (pawns & ~file_bb(pawnFile)) == EmptyBoardBB)
{
// All pawns are on a single rook file ?
if ( (pawnFile == FILE_A || pawnFile == FILE_H)
&& (pawns & ~file_bb(pawnFile)) == EmptyBoardBB)
{
- Square bishopSq = pos.piece_list(strongerSide, BISHOP, 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);
Square queeningSq = relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
&& (pos.pieces(PAWN, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_2)))
&& (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
{
&& (pos.pieces(PAWN, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_2)))
&& (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
{
- Square rsq = pos.piece_list(weakerSide, ROOK, 0);
+ Square rsq = pos.piece_list(weakerSide, ROOK)[0];
if (pos.attacks_from<PAWN>(rsq, strongerSide) & pos.pieces(PAWN, weakerSide))
return SCALE_FACTOR_ZERO;
}
if (pos.attacks_from<PAWN>(rsq, strongerSide) & pos.pieces(PAWN, weakerSide))
return SCALE_FACTOR_ZERO;
}
assert(pos.piece_count(weakerSide, PAWN) == 0);
Square wksq = pos.king_square(strongerSide);
assert(pos.piece_count(weakerSide, PAWN) == 0);
Square wksq = pos.king_square(strongerSide);
- Square wrsq = pos.piece_list(strongerSide, ROOK, 0);
- Square wpsq = pos.piece_list(strongerSide, PAWN, 0);
+ Square wrsq = pos.piece_list(strongerSide, ROOK)[0];
+ Square wpsq = pos.piece_list(strongerSide, PAWN)[0];
Square bksq = pos.king_square(weakerSide);
Square bksq = pos.king_square(weakerSide);
- Square brsq = pos.piece_list(weakerSide, ROOK, 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.
// 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.piece_count(weakerSide, PAWN) == 1);
assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
assert(pos.piece_count(weakerSide, PAWN) == 1);
- Square wpsq1 = pos.piece_list(strongerSide, PAWN, 0);
- Square wpsq2 = pos.piece_list(strongerSide, PAWN, 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?
Square bksq = pos.king_square(weakerSide);
// Does the stronger side have a passed pawn?
assert(pos.piece_count(weakerSide, BISHOP) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
assert(pos.piece_count(weakerSide, BISHOP) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 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 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
Square weakerKingSq = pos.king_square(weakerSide);
// Case 1: Defending king blocks the pawn, and cannot be driven away
assert(pos.piece_count(weakerSide, BISHOP) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
assert(pos.piece_count(weakerSide, BISHOP) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
- Square wbsq = pos.piece_list(strongerSide, BISHOP, 0);
- Square bbsq = pos.piece_list(weakerSide, BISHOP, 0);
+ Square wbsq = pos.piece_list(strongerSide, BISHOP)[0];
+ Square bbsq = pos.piece_list(weakerSide, BISHOP)[0];
if (!opposite_color_squares(wbsq, bbsq))
return SCALE_FACTOR_NONE;
Square ksq = pos.king_square(weakerSide);
if (!opposite_color_squares(wbsq, bbsq))
return SCALE_FACTOR_NONE;
Square ksq = pos.king_square(weakerSide);
- Square psq1 = pos.piece_list(strongerSide, PAWN, 0);
- Square psq2 = pos.piece_list(strongerSide, PAWN, 1);
+ Square psq1 = pos.piece_list(strongerSide, PAWN)[0];
+ Square psq2 = pos.piece_list(strongerSide, PAWN)[1];
Rank r1 = square_rank(psq1);
Rank r2 = square_rank(psq2);
Square blockSq1, blockSq2;
Rank r1 = square_rank(psq1);
Rank r2 = square_rank(psq2);
Square blockSq1, blockSq2;
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
assert(pos.piece_count(weakerSide, KNIGHT) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
- Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
- Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 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)
Square weakerKingSq = pos.king_square(weakerSide);
if ( square_file(weakerKingSq) == square_file(pawnSq)
assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
assert(pos.piece_count(weakerSide, PAWN) == 0);
assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
assert(pos.piece_count(weakerSide, PAWN) == 0);
- Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
+ Square pawnSq = pos.piece_list(strongerSide, PAWN)[0];
Square weakerKingSq = pos.king_square(weakerSide);
if ( pawnSq == relative_square(strongerSide, SQ_A7)
Square weakerKingSq = pos.king_square(weakerSide);
if ( pawnSq == relative_square(strongerSide, SQ_A7)
{
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
{
wksq = pos.king_square(WHITE);
bksq = pos.king_square(BLACK);
- wpsq = pos.piece_list(WHITE, PAWN, 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));
stm = pos.side_to_move();
}
else
{
wksq = flip_square(pos.king_square(BLACK));
bksq = flip_square(pos.king_square(WHITE));
- wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
+ wpsq = flip_square(pos.piece_list(BLACK, PAWN)[0]);
stm = opposite_color(pos.side_to_move());
}
stm = opposite_color(pos.side_to_move());
}
const BitCountType Full = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64 : CNT32;
const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
const Color Them = (Us == WHITE ? BLACK : WHITE);
const BitCountType Full = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64 : CNT32;
const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
const Color Them = (Us == WHITE ? BLACK : WHITE);
- const Square* ptr = pos.piece_list_begin(Us, Piece);
+ const Square* pl = pos.piece_list(Us, Piece);
ei.attackedBy[Us][Piece] = EmptyBoardBB;
ei.attackedBy[Us][Piece] = EmptyBoardBB;
- while ((s = *ptr++) != SQ_NONE)
+ while ((s = *pl++) != SQ_NONE)
{
// Find attacked squares, including x-ray attacks for bishops and rooks
if (Piece == KNIGHT || Piece == QUEEN)
{
// Find attacked squares, including x-ray attacks for bishops and rooks
if (Piece == KNIGHT || Piece == QUEEN)
Bitboard checkSqs, b;
Square from;
Bitboard checkSqs, b;
Square from;
- const Square* ptr = pos.piece_list_begin(us, Pt);
+ const Square* pl = pos.piece_list(us, Pt);
- if ((from = *ptr++) == SQ_NONE)
+ if ((from = *pl++) == SQ_NONE)
return mlist;
checkSqs = pos.attacks_from<Pt>(ksq) & pos.empty_squares();
return mlist;
checkSqs = pos.attacks_from<Pt>(ksq) & pos.empty_squares();
b = pos.attacks_from<Pt>(from) & checkSqs;
SERIALIZE_MOVES(b);
b = pos.attacks_from<Pt>(from) & checkSqs;
SERIALIZE_MOVES(b);
- } while ((from = *ptr++) != SQ_NONE);
+ } while ((from = *pl++) != SQ_NONE);
- const Square* ptr = pos.piece_list_begin(us, Pt);
+ const Square* pl = pos.piece_list(us, Pt);
b = pos.attacks_from<Pt>(from) & target;
SERIALIZE_MOVES(b);
b = pos.attacks_from<Pt>(from) & target;
SERIALIZE_MOVES(b);
- } while (*++ptr != SQ_NONE);
+ } while (*++pl != SQ_NONE);
Rank r;
bool passed, isolated, doubled, opposed, chain, backward, candidate;
Score value = SCORE_ZERO;
Rank r;
bool passed, isolated, doubled, opposed, chain, backward, candidate;
Score value = SCORE_ZERO;
- const Square* ptr = pos.piece_list_begin(Us, PAWN);
+ const Square* pl = pos.piece_list(Us, PAWN);
// Loop through all pawns of the current color and score each pawn
// Loop through all pawns of the current color and score each pawn
- while ((s = *ptr++) != SQ_NONE)
+ while ((s = *pl++) != SQ_NONE)
{
assert(pos.piece_on(s) == make_piece(Us, PAWN));
{
assert(pos.piece_on(s) == make_piece(Us, PAWN));
for (PieceType pt = PAWN; pt <= KING; pt++)
for (int i = 0; i < pieceCount[c][pt]; i++)
{
for (PieceType pt = PAWN; pt <= KING; pt++)
for (int i = 0; i < pieceCount[c][pt]; i++)
{
- if (piece_on(piece_list(c, pt, i)) != make_piece(c, pt))
+ if (piece_on(piece_list(c, pt)[i]) != make_piece(c, pt))
- if (index[piece_list(c, pt, i)] != i)
+ if (index[piece_list(c, pt)[i]] != i)
bool in_check() const;
// Piece lists
bool in_check() const;
// Piece lists
- Square piece_list(Color c, PieceType pt, int index) const;
- const Square* piece_list_begin(Color c, PieceType pt) const;
+ const Square* piece_list(Color c, PieceType pt) const;
// Information about attacks to or from a given square
Bitboard attackers_to(Square s) const;
// Information about attacks to or from a given square
Bitboard attackers_to(Square s) const;
return pieceCount[c][pt];
}
return pieceCount[c][pt];
}
-inline Square Position::piece_list(Color c, PieceType pt, int idx) const {
- return pieceList[c][pt][idx];
-}
-
-inline const Square* Position::piece_list_begin(Color c, PieceType pt) const {
+inline const Square* Position::piece_list(Color c, PieceType pt) const {
return pieceList[c][pt];
}
return pieceList[c][pt];
}
inline bool Position::opposite_colored_bishops() const {
return piece_count(WHITE, BISHOP) == 1 && piece_count(BLACK, BISHOP) == 1
inline bool Position::opposite_colored_bishops() const {
return piece_count(WHITE, BISHOP) == 1 && piece_count(BLACK, BISHOP) == 1
- && opposite_color_squares(piece_list(WHITE, BISHOP, 0), piece_list(BLACK, BISHOP, 0));
+ && opposite_color_squares(piece_list(WHITE, BISHOP)[0], piece_list(BLACK, BISHOP)[0]);
}
inline bool Position::has_pawn_on_7th(Color c) const {
}
inline bool Position::has_pawn_on_7th(Color c) const {