From: Marco Costalba Date: Sun, 19 Oct 2008 12:44:25 +0000 (+0100) Subject: Remove Position::xxx_list() functions X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=1eae58523f4fbf77b64d12e9e81a67612708f2f5 Remove Position::xxx_list() functions No useful, only obfuscating. Signed-off-by: Marco Costalba --- diff --git a/src/endgame.cpp b/src/endgame.cpp index 366a02d1..ee8b9179 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -247,7 +247,7 @@ Value KBNKEvaluationFunction::apply(const Position &pos) { 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); @@ -277,13 +277,13 @@ Value KPKEvaluationFunction::apply(const Position &pos) { 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()); } @@ -319,9 +319,9 @@ Value KRKPEvaluationFunction::apply(const Position &pos) { 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); @@ -388,7 +388,7 @@ Value KRKNEvaluationFunction::apply(const Position &pos) { 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)); @@ -434,13 +434,13 @@ ScaleFactor KBPKScalingFunction::apply(const Position &pos) { // 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); @@ -490,7 +490,7 @@ ScaleFactor KQKRPScalingFunction::apply(const Position &pos) { (pos.rooks(weakerSide) & relative_rank_bb(weakerSide, RANK_3)) && (pos.pawns(weakerSide) & relative_rank_bb(weakerSide, RANK_2)) && (pos.piece_attacks(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); } @@ -513,10 +513,10 @@ ScaleFactor KRPKRScalingFunction::apply(const Position &pos) { 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: @@ -617,8 +617,8 @@ ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) { 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? @@ -700,9 +700,9 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) { 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. @@ -754,8 +754,8 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) { 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) @@ -779,7 +779,7 @@ ScaleFactor KNPKScalingFunction::apply(const Position &pos) { 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) && @@ -813,13 +813,13 @@ ScaleFactor KPKPScalingFunction::apply(const Position &pos) { 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()); } diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 4bda8466..1b333b39 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -338,19 +338,19 @@ Value evaluate(const Position &pos, EvalInfo &ei, int threadID) { { // 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]; @@ -783,7 +783,7 @@ namespace { // 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(from), to) && !bit_is_set(p.pinned_pieces(them), from) && !(rook_attacks_bb(to, occ & clear_mask_bb(from)) & p.rooks_and_queens(us)) diff --git a/src/position.h b/src/position.h index 91e0a5b6..bf9bba3d 100644 --- a/src/position.h +++ b/src/position.h @@ -205,13 +205,8 @@ public: // 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; @@ -522,26 +517,6 @@ inline Square Position::piece_list(Color c, PieceType pt, int index) 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; } @@ -754,8 +729,8 @@ inline int Position::rule_50_counter() const { 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 {