]> git.sesse.net Git - stockfish/commitdiff
Retire pieces_of_color_and_type()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 14:09:52 +0000 (16:09 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 14:23:04 +0000 (16:23 +0200)
It is used mainly in a bunch of inline oneliners
just below its definition. So substitute it with
the explicit definition and avoid information hiding.

No functional change.

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

index 7f7df3c5465e491bc78775338f12de908fd3d6ab..a291ec466258b0bb336850e3444cffbccb4bc6f0 100644 (file)
@@ -930,7 +930,7 @@ namespace {
                     b3 |= (b2 & pos.pieces_of_color(them));
 
                     // There are no enemy pawns in the pawn's path
-                    assert((b2 & pos.pieces_of_color_and_type(them, PAWN)) == EmptyBoardBB);
+                    assert((b2 & pos.pieces_of_color(them) & pos.pieces_of_type(PAWN)) == EmptyBoardBB);
 
                     // Are any of the squares in the pawn's path attacked or occupied by the enemy?
                     if (b3 == EmptyBoardBB)
index bfeb7247c56b9c97085fc5ad2b26e57cb4eff8a7..bf8293b1259c824b8a8a91555793080d6ccfe928 100644 (file)
@@ -832,7 +832,7 @@ namespace {
   MoveStack* generate_piece_checks(const Position& pos, MoveStack* mlist, Color us,
                                    Bitboard dc, Square ksq) {
 
-    Bitboard target = pos.pieces_of_color_and_type(us, Piece);
+    Bitboard target = pos.pieces_of_color(us) & pos.pieces_of_type(Piece);
 
     // Discovered checks
     Bitboard b = target & dc;
index 0208d2a2a90ad8b4f7dc7b4110b1d053585973a5..9b8f779895a4337748abbc20b1e37b9dce54eaba 100644 (file)
@@ -1382,11 +1382,12 @@ int Position::see(Square from, Square to) const {
 
       // Locate the least valuable attacker to the destination square
       // and use it to initialize from square.
+      stmAttackers = attackers & pieces_of_color(us);
       PieceType pt;
-      for (pt = PAWN; !(attackers & pieces_of_color_and_type(us, pt)); pt++)
+      for (pt = PAWN; !(stmAttackers & pieces_of_type(pt)); pt++)
           assert(pt < KING);
 
-      from = first_1(attackers & pieces_of_color_and_type(us, pt));
+      from = first_1(stmAttackers & pieces_of_type(pt));
       piece = piece_on(from);
   }
 
@@ -1633,7 +1634,7 @@ Value Position::compute_value() const {
   for (Color c = WHITE; c <= BLACK; c++)
       for (PieceType pt = PAWN; pt <= KING; pt++)
       {
-          b = pieces_of_color_and_type(c, pt);
+          b = pieces_of_color(c) & pieces_of_type(pt);
           while(b)
           {
               s = pop_1st_bit(&b);
@@ -1659,7 +1660,7 @@ Value Position::compute_non_pawn_material(Color c) const {
 
   for (PieceType pt = KNIGHT; pt <= QUEEN; pt++)
   {
-      Bitboard b = pieces_of_color_and_type(c, pt);
+      Bitboard b = pieces_of_color(c) & pieces_of_type(pt);
       while (b)
       {
           assert(piece_on(first_1(b)) == piece_of_color_and_type(c, pt));
@@ -2011,7 +2012,7 @@ bool Position::is_ok(int* failedStep) const {
   if (debugPieceCounts)
       for (Color c = WHITE; c <= BLACK; c++)
           for (PieceType pt = PAWN; pt <= KING; pt++)
-              if (pieceCount[c][pt] != count_1s(pieces_of_color_and_type(c, pt)))
+              if (pieceCount[c][pt] != count_1s(pieces_of_color(c) & pieces_of_type(pt)))
                   return false;
 
   if (failedStep) (*failedStep)++;
@@ -2021,7 +2022,7 @@ 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)) != piece_of_color_and_type(c, pt))
+                  if (piece_on(piece_list(c, pt, i)) != (pieces_of_color(c) & pieces_of_type(pt)))
                       return false;
 
                   if (index[piece_list(c, pt, i)] != i)
index d1d511d7a99501245b5633ba76febe65ac9f000c..16e72519f130ee01820423928c217585ace81f04 100644 (file)
@@ -133,7 +133,7 @@ public:
   };
 
   // Constructors
-  Position() {};
+  Position() {}
   Position(const Position& pos);
   Position(const std::string& fen);
 
@@ -163,7 +163,6 @@ public:
   Bitboard occupied_squares() const;
   Bitboard pieces_of_color(Color c) const;
   Bitboard pieces_of_type(PieceType pt) const;
-  Bitboard pieces_of_color_and_type(Color c, PieceType pt) const;
   Bitboard pawns() const;
   Bitboard knights() const;
   Bitboard bishops() const;
@@ -414,10 +413,6 @@ inline Bitboard Position::pieces_of_type(PieceType pt) const {
   return byTypeBB[pt];
 }
 
-inline Bitboard Position::pieces_of_color_and_type(Color c, PieceType pt) const {
-  return pieces_of_color(c) & pieces_of_type(pt);
-}
-
 inline Bitboard Position::pawns() const {
   return pieces_of_type(PAWN);
 }
@@ -455,35 +450,35 @@ inline Bitboard Position::sliders() const {
 }
 
 inline Bitboard Position::pawns(Color c) const {
-  return pieces_of_color_and_type(c, PAWN);
+  return pieces_of_color(c) & pieces_of_type(PAWN);
 }
 
 inline Bitboard Position::knights(Color c) const {
-  return pieces_of_color_and_type(c, KNIGHT);
+  return pieces_of_color(c) & pieces_of_type(KNIGHT);
 }
 
 inline Bitboard Position::bishops(Color c) const {
-  return pieces_of_color_and_type(c, BISHOP);
+  return pieces_of_color(c) & pieces_of_type(BISHOP);
 }
 
 inline Bitboard Position::rooks(Color c) const {
-  return pieces_of_color_and_type(c, ROOK);
+  return pieces_of_color(c) & pieces_of_type(ROOK);
 }
 
 inline Bitboard Position::queens(Color c) const {
-  return pieces_of_color_and_type(c, QUEEN);
+  return pieces_of_color(c) & pieces_of_type(QUEEN);
 }
 
 inline Bitboard Position::kings(Color c) const {
-  return pieces_of_color_and_type(c, KING);
+  return pieces_of_color(c) & pieces_of_type(KING);
 }
 
 inline Bitboard Position::rooks_and_queens(Color c) const {
-  return rooks_and_queens() & pieces_of_color(c);
+  return pieces_of_color(c) & rooks_and_queens();
 }
 
 inline Bitboard Position::bishops_and_queens(Color c) const {
-  return bishops_and_queens() & pieces_of_color(c);
+  return pieces_of_color(c) & bishops_and_queens();
 }
 
 inline int Position::piece_count(Color c, PieceType pt) const {