]> git.sesse.net Git - stockfish/commitdiff
Rename pieces_of_color() in pieces()
authorMarco Costalba <mcostalba@gmail.com>
Tue, 28 Jun 2011 13:36:39 +0000 (15:36 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 28 Jun 2011 16:10:44 +0000 (17:10 +0100)
To be uniform with other overloads.

No functional change.

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

index 2cfa4d5a6e3f594a8002e45eebe77adbb7bef727..f7ae19775dbdfba7d173e2e36315ef6437b61d50 100644 (file)
@@ -619,7 +619,7 @@ namespace {
     Score score = SCORE_ZERO;
 
     // Enemy pieces not defended by a pawn and under our attack
-    Bitboard weakEnemies =  pos.pieces_of_color(Them)
+    Bitboard weakEnemies =  pos.pieces(Them)
                           & ~ei.attackedBy[Them][PAWN]
                           & ei.attackedBy[Us][0];
     if (!weakEnemies)
@@ -651,7 +651,7 @@ namespace {
     Score score = mobility = SCORE_ZERO;
 
     // Do not include in mobility squares protected by enemy pawns or occupied by our pieces
-    const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces_of_color(Us));
+    const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces(Us));
 
     score += evaluate_pieces<KNIGHT, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea);
     score += evaluate_pieces<BISHOP, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea);
@@ -705,7 +705,7 @@ namespace {
 
         // Analyse enemy's safe queen contact checks. First find undefended
         // squares around the king attacked by enemy queen...
-        b = undefended & ei.attackedBy[Them][QUEEN] & ~pos.pieces_of_color(Them);
+        b = undefended & ei.attackedBy[Them][QUEEN] & ~pos.pieces(Them);
         if (b)
         {
             // ...then remove squares not supported by another enemy piece
@@ -719,7 +719,7 @@ namespace {
 
         // Analyse enemy's safe rook contact checks. First find undefended
         // squares around the king attacked by enemy rooks...
-        b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces_of_color(Them);
+        b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces(Them);
 
         // Consider only squares where the enemy rook gives check
         b &= RookPseudoAttacks[ksq];
@@ -736,7 +736,7 @@ namespace {
         }
 
         // Analyse enemy's safe distance checks for sliders and knights
-        safe = ~(pos.pieces_of_color(Them) | ei.attackedBy[Us][0]);
+        safe = ~(pos.pieces(Them) | ei.attackedBy[Us][0]);
 
         b1 = pos.attacks_from<ROOK>(ksq) & safe;
         b2 = pos.attacks_from<BISHOP>(ksq) & safe;
@@ -832,7 +832,7 @@ namespace {
                     && (squares_in_front_of(Them, s) & pos.pieces(ROOK, QUEEN, Them) & pos.attacks_from<ROOK>(s)))
                     unsafeSquares = squaresToQueen;
                 else
-                    unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | pos.pieces_of_color(Them));
+                    unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | pos.pieces(Them));
 
                 // If there aren't enemy attacks or pieces along the path to queen give
                 // huge bonus. Even bigger if we protect the pawn's path.
@@ -847,7 +847,7 @@ namespace {
 
                 // At last, add a small bonus when there are no *friendly* pieces
                 // in the pawn's path.
-                if (!(squaresToQueen & pos.pieces_of_color(Us)))
+                if (!(squaresToQueen & pos.pieces(Us)))
                     ebonus += Value(rr);
             }
         } // rr != 0
@@ -924,10 +924,10 @@ namespace {
             // Opponent king cannot block because path is defended and position
             // is not in check. So only friendly pieces can be blockers.
             assert(!pos.in_check());
-            assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces_of_color(c)));
+            assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces(c)));
 
             // Add moves needed to free the path from friendly pieces and retest condition
-            movesToGo += count_1s<Max15>(queeningPath & pos.pieces_of_color(c));
+            movesToGo += count_1s<Max15>(queeningPath & pos.pieces(c));
 
             if (movesToGo >= oppMovesToGo && !pathDefended)
                 continue;
index cc635b84e37160a59cf004fff974d18124397869..9b4cc130b2268fb0e6029b9bf2b547741ac46bf9 100644 (file)
@@ -157,7 +157,7 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) {
   Bitboard target;
 
   if (Type == MV_CAPTURE || Type == MV_NON_EVASION)
-      target = pos.pieces_of_color(opposite_color(us));
+      target = pos.pieces(opposite_color(us));
   else if (Type == MV_NON_CAPTURE)
       target = pos.empty_squares();
   else
@@ -289,7 +289,7 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
   } while (b);
 
   // Generate evasions for king, capture and non capture moves
-  b = pos.attacks_from<KING>(ksq) & ~pos.pieces_of_color(us) & ~sliderAttacks;
+  b = pos.attacks_from<KING>(ksq) & ~pos.pieces(us) & ~sliderAttacks;
   from = ksq;
   SERIALIZE_MOVES(b);
 
@@ -411,7 +411,7 @@ namespace {
     Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares;
     Bitboard pawns = pos.pieces(PAWN, Us);
     Bitboard pawnsOn7 = pawns & TRank7BB;
-    Bitboard enemyPieces = (Type == MV_CAPTURE ? target : pos.pieces_of_color(Them));
+    Bitboard enemyPieces = (Type == MV_CAPTURE ? target : pos.pieces(Them));
 
     // Pre-calculate pawn pushes before changing emptySquares definition
     if (Type != MV_CAPTURE)
@@ -518,7 +518,7 @@ namespace {
     // It is a bit complicated to correctly handle Chess960
     for (s = Min(ksq, s1); s <= Max(ksq, s1); s++)
         if (  (s != ksq && s != rsq && !pos.square_is_empty(s))
-            ||(pos.attackers_to(s) & pos.pieces_of_color(them)))
+            ||(pos.attackers_to(s) & pos.pieces(them)))
             illegal = true;
 
     for (s = Min(rsq, s2); s <= Max(rsq, s2); s++)
index 77c0647a940b33165bd4217bfe1a090b5030a3d2..eb3cb895b51b7e1e2acccafe6899ff01ff41a432 100644 (file)
@@ -364,7 +364,7 @@ template<bool FindPinned>
 Bitboard Position::hidden_checkers(Color c) const {
 
   Bitboard result = EmptyBoardBB;
-  Bitboard pinners = pieces_of_color(FindPinned ? opposite_color(c) : c);
+  Bitboard pinners = pieces(FindPinned ? opposite_color(c) : c);
 
   // Pinned pieces protect our king, dicovery checks attack
   // the enemy king.
@@ -384,7 +384,7 @@ Bitboard Position::hidden_checkers(Color c) const {
       assert(b);
 
       if (  !(b & (b - 1)) // Only one bit set?
-          && (b & pieces_of_color(c))) // Is an our piece?
+          && (b & pieces(c))) // Is an our piece?
           result |= b;
   }
   return result;
@@ -485,7 +485,7 @@ bool Position::move_attacks_square(Move m, Square s) const {
   do_move_bb(&occ, make_move_bb(f, t));
   xray = ( (rook_attacks_bb(s, occ)   & pieces(ROOK, QUEEN))
           |(bishop_attacks_bb(s, occ) & pieces(BISHOP, QUEEN)))
-         & pieces_of_color(piece_color(piece_on(f)));
+         & pieces(piece_color(piece_on(f)));
 
   // If we have attacks we need to verify that are caused by our move
   // and are not already existent ones.
@@ -502,7 +502,7 @@ bool Position::move_attacks_square(Move m, Square s) const {
 void Position::find_checkers() {
 
   Color us = side_to_move();
-  st->checkersBB = attackers_to(king_square(us)) & pieces_of_color(opposite_color(us));
+  st->checkersBB = attackers_to(king_square(us)) & pieces(opposite_color(us));
 }
 
 
@@ -548,7 +548,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   // square is attacked by the opponent. Castling moves are checked
   // for legality during move generation.
   if (piece_type(piece_on(from)) == KING)
-      return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
+      return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces(opposite_color(us)));
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
@@ -681,7 +681,7 @@ bool Position::move_is_pl(const Move m) const {
       {
           Bitboard b = occupied_squares();
           clear_bit(&b, from);
-          if (attackers_to(move_to(m), b) & pieces_of_color(opposite_color(us)))
+          if (attackers_to(move_to(m), b) & pieces(opposite_color(us)))
               return false;
       }
       else
@@ -1010,7 +1010,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
   if (moveIsCheck)
   {
       if (ep | pm)
-          st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us);
+          st->checkersBB = attackers_to(king_square(them)) & pieces(us);
       else
       {
           // Direct checks
@@ -1188,7 +1188,7 @@ void Position::do_castle_move(Move m) {
   st->rule50 = 0;
 
   // Update checkers BB
-  st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us);
+  st->checkersBB = attackers_to(king_square(them)) & pieces(us);
 
   // Finish
   sideToMove = opposite_color(sideToMove);
@@ -1491,7 +1491,7 @@ int Position::see(Move m) const {
 
   // If the opponent has no attackers we are finished
   stm = opposite_color(piece_color(piece_on(from)));
-  stmAttackers = attackers & pieces_of_color(stm);
+  stmAttackers = attackers & pieces(stm);
   if (!stmAttackers)
       return PieceValueMidgame[capturedType];
 
@@ -1529,7 +1529,7 @@ int Position::see(Move m) const {
       // move before beginning the next iteration.
       capturedType = pt;
       stm = opposite_color(stm);
-      stmAttackers = attackers & pieces_of_color(stm);
+      stmAttackers = attackers & pieces(stm);
 
       // Stop before processing a king capture
       if (capturedType == KING && stmAttackers)
@@ -1881,7 +1881,7 @@ bool Position::is_ok(int* failedStep) const {
       Color us = side_to_move();
       Color them = opposite_color(us);
       Square ksq = king_square(them);
-      if (attackers_to(ksq) & pieces_of_color(us))
+      if (attackers_to(ksq) & pieces(us))
           return false;
   }
 
@@ -1895,12 +1895,12 @@ bool Position::is_ok(int* failedStep) const {
   if (debugBitboards)
   {
       // The intersection of the white and black pieces must be empty
-      if ((pieces_of_color(WHITE) & pieces_of_color(BLACK)) != EmptyBoardBB)
+      if ((pieces(WHITE) & pieces(BLACK)) != EmptyBoardBB)
           return false;
 
       // The union of the white and black pieces must be equal to all
       // occupied squares
-      if ((pieces_of_color(WHITE) | pieces_of_color(BLACK)) != occupied_squares())
+      if ((pieces(WHITE) | pieces(BLACK)) != occupied_squares())
           return false;
 
       // Separate piece type bitboards must have empty intersections
index 244d365ba47a67d400cd62fb854886f94de9fa82..9e4a6e4c3fba00c9b7b06ebda6687cdc50d01982 100644 (file)
@@ -137,7 +137,7 @@ public:
   // Bitboard representation of the position
   Bitboard empty_squares() const;
   Bitboard occupied_squares() const;
-  Bitboard pieces_of_color(Color c) const;
+  Bitboard pieces(Color c) const;
   Bitboard pieces(PieceType pt) const;
   Bitboard pieces(PieceType pt, Color c) const;
   Bitboard pieces(PieceType pt1, PieceType pt2) const;
@@ -333,7 +333,7 @@ inline Bitboard Position::empty_squares() const {
   return ~occupied_squares();
 }
 
-inline Bitboard Position::pieces_of_color(Color c) const {
+inline Bitboard Position::pieces(Color c) const {
   return byColorBB[c];
 }
 
index daf40dec7cc05a9c1b6f336bf9b3bb062d4311e2..092f7d73ed084be2a4a6881890d23a429e072523 100644 (file)
@@ -1524,7 +1524,7 @@ split_point_start: // At split points actual search starts from here
     newAtt = pos.attacks_from(pc,   to, occ);
 
     // Rule 1. Checks which give opponent's king at most one escape square are dangerous
-    b = kingAtt & ~pos.pieces_of_color(them) & ~newAtt & ~(1ULL << to);
+    b = kingAtt & ~pos.pieces(them) & ~newAtt & ~(1ULL << to);
 
     if (!(b && (b & (b - 1))))
         return true;
@@ -1535,7 +1535,7 @@ split_point_start: // At split points actual search starts from here
         return true;
 
     // Rule 3. Creating new double threats with checks
-    b = pos.pieces_of_color(them) & newAtt & ~oldAtt & ~(1ULL << ksq);
+    b = pos.pieces(them) & newAtt & ~oldAtt & ~(1ULL << ksq);
 
     while (b)
     {