]> git.sesse.net Git - stockfish/commitdiff
Remove xxx_of_color() helpers
authorMarco Costalba <mcostalba@gmail.com>
Tue, 17 Feb 2009 09:54:47 +0000 (10:54 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 17 Feb 2009 09:54:47 +0000 (10:54 +0100)
They hide the underlying uniform function call with
no benefit.

A little bit more verbose but now is clear what happens.

No functional change.

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

index 04e4dded86474e507fd88974648e01888ea1d37b..ee626433019e2a3274636609081e7346b42edbef 100644 (file)
@@ -1074,7 +1074,7 @@ namespace {
     Square b6 = relative_square(us, (square_file(s) == FILE_A) ? SQ_B6 : SQ_G6);
     Square b8 = relative_square(us, (square_file(s) == FILE_A) ? SQ_B8 : SQ_G8);
 
-    if (   pos.piece_on(b6) == pawn_of_color(opposite_color(us))
+    if (   pos.piece_on(b6) == piece_of_color_and_type(opposite_color(us), PAWN)
         && pos.see(s, b6) < 0
         && pos.see(s, b8) < 0)
     {
@@ -1091,7 +1091,7 @@ namespace {
 
   void evaluate_trapped_bishop_a1h1(const Position &pos, Square s, Color us,
                                     EvalInfo &ei) {
-    Piece pawn = pawn_of_color(us);
+    Piece pawn = piece_of_color_and_type(us, PAWN);
     Square b2, b3, c3;
 
     assert(Chess960);
index 63800d7f83bde58caf67f7a91f1fc2ad25d65120..ad282dfb56da9104d15bbce3b2eae91d2ab09c97 100644 (file)
@@ -72,13 +72,13 @@ Move move_from_string(const Position& pos, const std::string& str) {
     }
   }
 
-  if (piece == king_of_color(us))
+  if (piece == piece_of_color_and_type(us, KING))
   {
       // Is this a castling move? A king move is assumed to be a castling
       // move if the destination square is occupied by a friendly rook, or
       // if the distance between the source and destination squares is more
       // than 1.
-      if (pos.piece_on(to) == rook_of_color(us))
+      if (pos.piece_on(to) == piece_of_color_and_type(us, ROOK))
           return make_castle_move(from, to);
 
       else if (square_distance(from, to) > 1)
@@ -87,13 +87,13 @@ Move move_from_string(const Position& pos, const std::string& str) {
           // internal "king captures rook" representation.
           SquareDelta delta = (to > from ? DELTA_E : DELTA_W);
           Square s = from + delta;
-          while (relative_rank(us, s) == RANK_1 && pos.piece_on(s) != rook_of_color(us))
+          while (relative_rank(us, s) == RANK_1 && pos.piece_on(s) != piece_of_color_and_type(us, ROOK))
               s += delta;
 
           return (relative_rank(us, s) == RANK_1 ? make_castle_move(from, s) : MOVE_NONE);
       }
   }
-  else if (piece == pawn_of_color(us))
+  else if (piece == piece_of_color_and_type(us, PAWN))
   {
       // En passant move? We assume that a pawn move is an en passant move
       // without further testing if the destination square is epSquare.
index bc56548da09f75fd27d4a9c8167f5de83bae100d..817b4f98f0763f01007e728299b23ff5ca8a5696 100644 (file)
@@ -467,8 +467,8 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
               illegal = true;
 
       if (   square_file(to) == FILE_B
-          && (   pos.piece_on(to + DELTA_W) == rook_of_color(them)
-              || pos.piece_on(to + DELTA_W) == queen_of_color(them)))
+          && (   pos.piece_on(to + DELTA_W) == piece_of_color_and_type(them, ROOK)
+              || pos.piece_on(to + DELTA_W) == piece_of_color_and_type(them, QUEEN)))
           illegal = true;
 
       return !illegal;
@@ -888,8 +888,8 @@ namespace {
 
         if (   Side == QUEEN_SIDE
             && square_file(rsq) == FILE_B
-            && (   pos.piece_on(relative_square(us, SQ_A1)) == rook_of_color(them)
-                || pos.piece_on(relative_square(us, SQ_A1)) == queen_of_color(them)))
+            && (   pos.piece_on(relative_square(us, SQ_A1)) == piece_of_color_and_type(them, ROOK)
+                || pos.piece_on(relative_square(us, SQ_A1)) == piece_of_color_and_type(them, QUEEN)))
             illegal = true;
 
         if (!illegal)
index d7f11b6c3a7ec7c3980efb3546d565a00bc742b6..be75a433867cd4e672e5a7013833f65ba8a03499 100644 (file)
@@ -111,30 +111,6 @@ inline Piece piece_of_color_and_type(Color c, PieceType pt) {
   return Piece((int(c) << 3) | int(pt));
 }
 
-inline Piece pawn_of_color(Color c) {
-  return piece_of_color_and_type(c, PAWN);
-}
-
-inline Piece knight_of_color(Color c) {
-  return piece_of_color_and_type(c, KNIGHT);
-}
-
-inline Piece bishop_of_color(Color c) {
-  return piece_of_color_and_type(c, BISHOP);
-}
-
-inline Piece rook_of_color(Color c) {
-  return piece_of_color_and_type(c, ROOK);
-}
-
-inline Piece queen_of_color(Color c) {
-  return piece_of_color_and_type(c, QUEEN);
-}
-
-inline Piece king_of_color(Color c) {
-  return piece_of_color_and_type(c, KING);
-}
-
 inline int piece_is_slider(Piece p) {
   return SlidingArray[int(p)];
 }
index 2585ef3c84c0775d4d4a965ac69e5f9281fa5128..501674d6a283bf734f5d79d2d0e7e904fb1b2bb0 100644 (file)
@@ -984,8 +984,8 @@ void Position::do_castle_move(Move m) {
 
   // Update board array
   board[kfrom] = board[rfrom] = EMPTY;
-  board[kto] = king_of_color(us);
-  board[rto] = rook_of_color(us);
+  board[kto] = piece_of_color_and_type(us, KING);
+  board[rto] = piece_of_color_and_type(us, ROOK);
 
   // Update king square
   kingSquare[us] = kto;
@@ -1348,8 +1348,8 @@ void Position::undo_castle_move(Move m) {
 
   // Update board
   board[rto] = board[kto] = EMPTY;
-  board[rfrom] = rook_of_color(us);
-  board[kfrom] = king_of_color(us);
+  board[rfrom] = piece_of_color_and_type(us, ROOK);
+  board[kfrom] = piece_of_color_and_type(us, KING);
 
   // Update king square
   kingSquare[us] = kfrom;
@@ -1400,7 +1400,7 @@ void Position::undo_promotion_move(Move m, const UndoInfo &u) {
   set_bit(&(byColorBB[us]), from);
   set_bit(&(byTypeBB[PAWN]), from);
   set_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
-  board[from] = pawn_of_color(us);
+  board[from] = piece_of_color_and_type(us, PAWN);
 
   // Update material
   npMaterial[us] -= piece_value_midgame(promotion);
@@ -1473,7 +1473,7 @@ void Position::undo_ep_move(Move m) {
   set_bit(&(byColorBB[them]), capsq);
   set_bit(&(byTypeBB[PAWN]), capsq);
   set_bit(&(byTypeBB[0]), capsq);
-  board[capsq] = pawn_of_color(them);
+  board[capsq] = piece_of_color_and_type(them, PAWN);
 
   // Remove moving piece from destination square
   clear_bit(&(byColorBB[us]), to);
@@ -1485,7 +1485,7 @@ void Position::undo_ep_move(Move m) {
   set_bit(&(byColorBB[us]), from);
   set_bit(&(byTypeBB[PAWN]), from);
   set_bit(&(byTypeBB[0]), from);
-  board[from] = pawn_of_color(us);
+  board[from] = piece_of_color_and_type(us, PAWN);
 
   // Update piece list:
   pieceList[us][PAWN][index[to]] = from;
index 3822e3bc5f225ee276724c9e3347b4e5fb772f19..8e2ecf6019b812eb5872e2f7db27d36d65ea2528 100644 (file)
@@ -529,12 +529,12 @@ inline Square Position::initial_qr_square(Color c) const {
 }
 
 inline Bitboard Position::pawn_attacks(Color c, Square s) const {
-  return StepAttackBB[pawn_of_color(c)][s];
+  return StepAttackBB[piece_of_color_and_type(c, PAWN)][s];
 }
 
 template<>
 inline Bitboard Position::piece_attacks<PAWN>(Square s) const {
-  return StepAttackBB[pawn_of_color(opposite_color(sideToMove))][s];
+  return StepAttackBB[piece_of_color_and_type(opposite_color(sideToMove), PAWN)][s];
 }
 
 template<>
@@ -675,28 +675,28 @@ inline Phase Position::game_phase() const {
 inline bool Position::move_is_deep_pawn_push(Move m) const {
 
   Color c = side_to_move();
-  return   piece_on(move_from(m)) == pawn_of_color(c)
+  return   piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
         && relative_rank(c, move_to(m)) > RANK_4;
 }
 
 inline bool Position::move_is_pawn_push_to_7th(Move m) const {
 
   Color c = side_to_move();
-  return   piece_on(move_from(m)) == pawn_of_color(c)
+  return   piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
         && relative_rank(c, move_to(m)) == RANK_7;
 }
 
 inline bool Position::move_is_passed_pawn_push(Move m) const {
 
   Color c = side_to_move();
-  return   piece_on(move_from(m)) == pawn_of_color(c)
+  return   piece_on(move_from(m)) == piece_of_color_and_type(c, PAWN)
         && pawn_is_passed(c, move_to(m));
 }
 
 inline bool Position::move_was_passed_pawn_push(Move m) const {
 
   Color c = opposite_color(side_to_move());
-  return   piece_on(move_to(m)) == pawn_of_color(c)
+  return   piece_on(move_to(m)) == piece_of_color_and_type(c, PAWN)
         && pawn_is_passed(c, move_to(m));
 }