]> git.sesse.net Git - stockfish/commitdiff
Retire one piece_list() overload
authorMarco Costalba <mcostalba@gmail.com>
Tue, 28 Jun 2011 14:16:43 +0000 (16:16 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 28 Jun 2011 16:11:03 +0000 (17:11 +0100)
No functional change.

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

index c8c491fdd60aaf304b023f26f12170ffb614161b..c1c703a3af2ce80583e97b0201517bcbc4c0b7ab 100644 (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());
   }
 
index f7ae19775dbdfba7d173e2e36315ef6437b61d50..6ae46f4199589c397596c1c18235414bcafe5601 100644 (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)
index 9b4cc130b2268fb0e6029b9bf2b547741ac46bf9..9b41f4f4d464f20c70d965e380e6943f8d636991 100644 (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;
   }
index 3ad88fb206aa011ece4fb6dca4c75acf17edb758..c099153a2ca5d7e1038d15a6ca01e934fcdfa859 100644 (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));
 
index eb3cb895b51b7e1e2acccafe6899ff01ff41a432..8a902502acbee50006dfdd4016272b7a4f4fd032 100644 (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;
               }
 
index 9e4a6e4c3fba00c9b7b06ebda6687cdc50d01982..e7fc9a2eb6ca9dcbeca2acaf7b9b596fdde47996 100644 (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 {