]> git.sesse.net Git - stockfish/commitdiff
Remove Position::xxx_list() functions
authorMarco Costalba <mcostalba@gmail.com>
Sun, 19 Oct 2008 12:44:25 +0000 (13:44 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 19 Oct 2008 12:44:25 +0000 (13:44 +0100)
No useful, only obfuscating.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/endgame.cpp
src/evaluate.cpp
src/position.h

index 366a02d1137458b80085034af0577b4a82903e18..ee8b9179c2d79ecfab93a197b329cd353041604d 100644 (file)
@@ -247,7 +247,7 @@ Value KBNKEvaluationFunction::apply(const Position &pos) {
 
   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.bishop_list(strongerSide, 0);
+  Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0);
 
   if(square_color(bishopSquare) == BLACK) {
     winnerKSq = flop_square(winnerKSq);
 
   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);
   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));
     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());
   }
 
     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);
   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);
   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);
 
   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);
   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));
 
   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);
   // 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.
 
 
   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);
     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<KING>(kingSq) & pos.pawns(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);
   }
     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);
   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 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:
 
   // 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);
 
   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?
   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);
 
   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.
   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);
 
   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)
   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);
 
   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) &&
   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);
   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));
     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());
   }
 
     stm = opposite_color(pos.side_to_move());
   }
 
index 4bda8466e1fdaeddc3e346376d4a37f2a038dbae..1b333b39fd21fa8643c283077dc13173bba79a79 100644 (file)
@@ -338,19 +338,19 @@ Value evaluate(const Position &pos, EvalInfo &ei, int threadID) {
   {
     // Knights
     for (int i = 0; i < pos.knight_count(c); i++)
   {
     // 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++)
 
     // 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++)
 
     // 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++)
 
     // 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];
 
     // 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++)
                     {
                     // 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))
                         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))
index 91e0a5b69767ee247a3aa330e290708334ee06ea..bf9bba3d492f8529903946564fe6c14ca12ab024 100644 (file)
@@ -205,13 +205,8 @@ public:
   // Checking pieces
   Bitboard checkers() const;
 
   // Checking pieces
   Bitboard checkers() const;
 
-  // Piece lists:
+  // Piece lists
   Square piece_list(Color c, PieceType pt, int index) const;
   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;
 
   // 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];
 }
 
   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 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
 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 {
 }
 
 inline bool Position::has_pawn_on_7th(Color c) const {