1
0
Fork 0

Retire one piece_list() overload

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
sf_2.3.1_base
Marco Costalba 2011-06-28 16:16:43 +02:00
parent e5077dc11e
commit e0a00c4996
6 changed files with 43 additions and 48 deletions

View File

@ -196,7 +196,7 @@ Value Endgame<Value, KBNK>::apply(const Position& pos) const {
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
@ -231,14 +231,14 @@ Value Endgame<Value, KPK>::apply(const Position& pos) const {
{
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));
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());
}
@ -276,9 +276,9 @@ Value Endgame<Value, KRKP>::apply(const Position& pos) const {
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);
bpsq = pos.piece_list(weakerSide, PAWN, 0);
bpsq = pos.piece_list(weakerSide, PAWN)[0];
if (strongerSide == BLACK)
{
@ -347,7 +347,7 @@ Value Endgame<Value, KRKN>::apply(const Position& pos) const {
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)
@ -394,7 +394,7 @@ Value Endgame<Value, KBBKN>::apply(const Position& pos) const {
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)]);
@ -437,13 +437,13 @@ ScaleFactor Endgame<ScaleFactor, KBPsK>::apply(const Position& pos) const {
// 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)
{
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);
@ -496,7 +496,7 @@ ScaleFactor Endgame<ScaleFactor, KQKRPs>::apply(const Position& pos) const {
&& (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;
}
@ -520,10 +520,10 @@ ScaleFactor Endgame<ScaleFactor, KRPKR>::apply(const Position& pos) const {
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 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.
@ -637,8 +637,8 @@ ScaleFactor Endgame<ScaleFactor, KRPPKRP>::apply(const Position& pos) const {
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?
@ -716,9 +716,9 @@ ScaleFactor Endgame<ScaleFactor, KBPKB>::apply(const Position& pos) const {
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
@ -771,15 +771,15 @@ ScaleFactor Endgame<ScaleFactor, KBPPKB>::apply(const Position& pos) const {
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);
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;
@ -847,8 +847,8 @@ ScaleFactor Endgame<ScaleFactor, KBPKN>::apply(const Position& pos) const {
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)
@ -873,7 +873,7 @@ ScaleFactor Endgame<ScaleFactor, KNPK>::apply(const Position& pos) const {
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)
@ -909,14 +909,14 @@ ScaleFactor Endgame<ScaleFactor, KPKP>::apply(const Position& pos) const {
{
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));
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());
}

View File

@ -486,11 +486,11 @@ namespace {
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;
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)

View File

@ -64,9 +64,9 @@ namespace {
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();
@ -84,7 +84,7 @@ namespace {
b = pos.attacks_from<Pt>(from) & checkSqs;
SERIALIZE_MOVES(b);
} while ((from = *ptr++) != SQ_NONE);
} while ((from = *pl++) != SQ_NONE);
return mlist;
}
@ -111,15 +111,15 @@ namespace {
Bitboard b;
Square from;
const Square* ptr = pos.piece_list_begin(us, Pt);
const Square* pl = pos.piece_list(us, Pt);
if (*ptr != SQ_NONE)
if (*pl != SQ_NONE)
{
do {
from = *ptr;
from = *pl;
b = pos.attacks_from<Pt>(from) & target;
SERIALIZE_MOVES(b);
} while (*++ptr != SQ_NONE);
} while (*++pl != SQ_NONE);
}
return mlist;
}

View File

@ -127,10 +127,10 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
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
while ((s = *ptr++) != SQ_NONE)
while ((s = *pl++) != SQ_NONE)
{
assert(pos.piece_on(s) == make_piece(Us, PAWN));

View File

@ -1965,10 +1965,10 @@ 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)) != make_piece(c, pt))
if (piece_on(piece_list(c, pt)[i]) != make_piece(c, pt))
return false;
if (index[piece_list(c, pt, i)] != i)
if (index[piece_list(c, pt)[i]] != i)
return false;
}

View File

@ -166,8 +166,7 @@ public:
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;
@ -357,11 +356,7 @@ inline int Position::piece_count(Color c, PieceType pt) const {
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];
}
@ -472,7 +467,7 @@ inline int Position::full_moves() const {
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 {