]> git.sesse.net Git - stockfish/commitdiff
Remove xxx_of_color() for real
authorMarco Costalba <mcostalba@gmail.com>
Tue, 17 Feb 2009 16:26:15 +0000 (17:26 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 17 Feb 2009 16:26:15 +0000 (17:26 +0100)
Remove also from assert expressions. Was hidden
in release mode.

No functional change.

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

index a01a3c2c08c4b4089296129a0291734b548af04b..4984d08ce53c5344b8e1937fb7f8263df6e8e819 100644 (file)
@@ -926,7 +926,7 @@ namespace {
         {
             Square s = pop_1st_bit(&b);
 
         {
             Square s = pop_1st_bit(&b);
 
-            assert(pos.piece_on(s) == pawn_of_color(us));
+            assert(pos.piece_on(s) == piece_of_color_and_type(us, PAWN));
             assert(pos.pawn_is_passed(us, s));
 
             int r = int(relative_rank(us, s) - RANK_2);
             assert(pos.pawn_is_passed(us, s));
 
             int r = int(relative_rank(us, s) - RANK_2);
@@ -1077,7 +1077,7 @@ namespace {
   void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
                                     EvalInfo &ei) {
     assert(square_is_ok(s));
   void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
                                     EvalInfo &ei) {
     assert(square_is_ok(s));
-    assert(pos.piece_on(s) == bishop_of_color(us));
+    assert(pos.piece_on(s) == piece_of_color_and_type(us, BISHOP));
 
     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);
 
     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);
@@ -1104,7 +1104,7 @@ namespace {
 
     assert(Chess960);
     assert(square_is_ok(s));
 
     assert(Chess960);
     assert(square_is_ok(s));
-    assert(pos.piece_on(s) == bishop_of_color(us));
+    assert(pos.piece_on(s) == piece_of_color_and_type(us, BISHOP));
 
     if (square_file(s) == FILE_A)
     {
 
     if (square_file(s) == FILE_A)
     {
index a002e19fe98c92b64f29e547143633ba619e1416..258f9c710616a208339b055599f999c0817b382a 100644 (file)
@@ -175,7 +175,7 @@ int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
   Square ksq = pos.king_square(opposite_color(us));
   MoveStack* mlist_start = mlist;
 
   Square ksq = pos.king_square(opposite_color(us));
   MoveStack* mlist_start = mlist;
 
-  assert(pos.piece_on(ksq) == king_of_color(opposite_color(us)));
+  assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));
 
   // Pieces moves
   mlist = generate_piece_checks<PAWN>(pos, mlist, us, dc, ksq);
 
   // Pieces moves
   mlist = generate_piece_checks<PAWN>(pos, mlist, us, dc, ksq);
@@ -215,7 +215,7 @@ int generate_evasions(const Position& pos, MoveStack* mlist, Bitboard pinned) {
   Square ksq = pos.king_square(us);
   MoveStack* mlist_start = mlist;
 
   Square ksq = pos.king_square(us);
   MoveStack* mlist_start = mlist;
 
-  assert(pos.piece_on(ksq) == king_of_color(us));
+  assert(pos.piece_on(ksq) == piece_of_color_and_type(us, KING));
 
   // The bitboard of occupied pieces without our king
   Bitboard b_noKing = pos.occupied_squares();
 
   // The bitboard of occupied pieces without our king
   Bitboard b_noKing = pos.occupied_squares();
@@ -400,7 +400,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
           return false;
 
       assert(pos.square_is_empty(to));
           return false;
 
       assert(pos.square_is_empty(to));
-      assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
+      assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN));
 
       // The move is pseudo-legal, check if it is also legal
       return pos.pl_move_is_legal(m, pinned);
 
       // The move is pseudo-legal, check if it is also legal
       return pos.pl_move_is_legal(m, pinned);
@@ -417,7 +417,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
 
       assert(from == pos.king_square(us));
       assert(to == pos.initial_kr_square(us));
 
       assert(from == pos.king_square(us));
       assert(to == pos.initial_kr_square(us));
-      assert(pos.piece_on(to) == rook_of_color(us));
+      assert(pos.piece_on(to) == piece_of_color_and_type(us, ROOK));
 
       Square g1 = relative_square(us, SQ_G1);
       Square f1 = relative_square(us, SQ_F1);
 
       Square g1 = relative_square(us, SQ_G1);
       Square f1 = relative_square(us, SQ_F1);
@@ -450,7 +450,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
 
       assert(from == pos.king_square(us));
       assert(to == pos.initial_qr_square(us));
 
       assert(from == pos.king_square(us));
       assert(to == pos.initial_qr_square(us));
-      assert(pos.piece_on(to) == rook_of_color(us));
+      assert(pos.piece_on(to) == piece_of_color_and_type(us, ROOK));
 
       Square c1 = relative_square(us, SQ_C1);
       Square d1 = relative_square(us, SQ_D1);
 
       Square c1 = relative_square(us, SQ_C1);
       Square d1 = relative_square(us, SQ_D1);
@@ -866,7 +866,7 @@ namespace {
         Color them = opposite_color(us);
         Square ksq = pos.king_square(us);
 
         Color them = opposite_color(us);
         Square ksq = pos.king_square(us);
 
-        assert(pos.piece_on(ksq) == king_of_color(us));
+        assert(pos.piece_on(ksq) == piece_of_color_and_type(us, KING));
 
         Square rsq = (Side == KING_SIDE ? pos.initial_kr_square(us) : pos.initial_qr_square(us));
         Square s1 = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
 
         Square rsq = (Side == KING_SIDE ? pos.initial_kr_square(us) : pos.initial_qr_square(us));
         Square s1 = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
@@ -874,7 +874,7 @@ namespace {
         Square s;
         bool illegal = false;
 
         Square s;
         bool illegal = false;
 
-        assert(pos.piece_on(rsq) == rook_of_color(us));
+        assert(pos.piece_on(rsq) == piece_of_color_and_type(us, ROOK));
 
         // It is a bit complicated to correctly handle Chess960
         for (s = Min(ksq, s1); s <= Max(ksq, s1); s++)
 
         // It is a bit complicated to correctly handle Chess960
         for (s = Min(ksq, s1); s <= Max(ksq, s1); s++)
index 6fd3e215b6fbee634489d76690fd101e5de5a89f..0aacec0026544b9f768fcd33641d09e7c38fb31e 100644 (file)
@@ -216,7 +216,7 @@ PawnInfo *PawnInfoTable::get_pawn_info(const Position &pos) {
         File f = square_file(s);
         Rank r = square_rank(s);
 
         File f = square_file(s);
         Rank r = square_rank(s);
 
-        assert(pos.piece_on(s) == pawn_of_color(us));
+        assert(pos.piece_on(s) == piece_of_color_and_type(us, PAWN));
 
         // The file containing the pawn is not half open
         pi->halfOpenFiles[us] &= ~(1 << f);
 
         // The file containing the pawn is not half open
         pi->halfOpenFiles[us] &= ~(1 << f);
index 1b1fef8ac3978a694209d8eacc18f754fb4f2971..382073a7020dc2a1199cc9e5604b1d8d91c85048 100644 (file)
@@ -493,7 +493,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   Square ksq = king_square(us);
 
   assert(color_of_piece_on(from) == us);
   Square ksq = king_square(us);
 
   assert(color_of_piece_on(from) == us);
-  assert(piece_on(ksq) == king_of_color(us));
+  assert(piece_on(ksq) == piece_of_color_and_type(us, KING));
 
   // En passant captures are a tricky special case.  Because they are
   // rather uncommon, we do it simply by testing whether the king is attacked
 
   // En passant captures are a tricky special case.  Because they are
   // rather uncommon, we do it simply by testing whether the king is attacked
@@ -505,8 +505,8 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
       Bitboard b = occupied_squares();
 
       assert(to == ep_square());
       Bitboard b = occupied_squares();
 
       assert(to == ep_square());
-      assert(piece_on(from) == pawn_of_color(us));
-      assert(piece_on(capsq) == pawn_of_color(them));
+      assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
+      assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
       assert(piece_on(to) == EMPTY);
 
       clear_bit(&b, from);
       assert(piece_on(to) == EMPTY);
 
       clear_bit(&b, from);
@@ -554,7 +554,7 @@ bool Position::move_is_check(Move m, Bitboard dcCandidates) const {
   Square ksq = king_square(them);
 
   assert(color_of_piece_on(from) == us);
   Square ksq = king_square(them);
 
   assert(color_of_piece_on(from) == us);
-  assert(piece_on(ksq) == king_of_color(them));
+  assert(piece_on(ksq) == piece_of_color_and_type(them, KING));
 
   // Proceed according to the type of the moving piece
   switch (type_of_piece_on(from))
 
   // Proceed according to the type of the moving piece
   switch (type_of_piece_on(from))
@@ -940,8 +940,8 @@ void Position::do_castle_move(Move m) {
   Square rfrom = move_to(m);  // HACK: See comment at beginning of function
   Square kto, rto;
 
   Square rfrom = move_to(m);  // HACK: See comment at beginning of function
   Square kto, rto;
 
-  assert(piece_on(kfrom) == king_of_color(us));
-  assert(piece_on(rfrom) == rook_of_color(us));
+  assert(piece_on(kfrom) == piece_of_color_and_type(us, KING));
+  assert(piece_on(rfrom) == piece_of_color_and_type(us, ROOK));
 
   // Find destination squares for king and rook
   if (rfrom > kfrom) // O-O
 
   // Find destination squares for king and rook
   if (rfrom > kfrom) // O-O
@@ -1039,7 +1039,7 @@ void Position::do_promotion_move(Move m, UndoInfo &u) {
   to = move_to(m);
 
   assert(relative_rank(us, to) == RANK_8);
   to = move_to(m);
 
   assert(relative_rank(us, to) == RANK_8);
-  assert(piece_on(from) == pawn_of_color(us));
+  assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
   assert(color_of_piece_on(to) == them || square_is_empty(to));
 
   capture = type_of_piece_on(to);
   assert(color_of_piece_on(to) == them || square_is_empty(to));
 
   capture = type_of_piece_on(to);
@@ -1136,8 +1136,8 @@ void Position::do_ep_move(Move m) {
   assert(to == epSquare);
   assert(relative_rank(us, to) == RANK_6);
   assert(piece_on(to) == EMPTY);
   assert(to == epSquare);
   assert(relative_rank(us, to) == RANK_6);
   assert(piece_on(to) == EMPTY);
-  assert(piece_on(from) == pawn_of_color(us));
-  assert(piece_on(capsq) == pawn_of_color(them));
+  assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
+  assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
 
   // Remove captured piece
   clear_bit(&(byColorBB[them]), capsq);
 
   // Remove captured piece
   clear_bit(&(byColorBB[them]), capsq);
@@ -1314,8 +1314,8 @@ void Position::undo_castle_move(Move m) {
       rto = relative_square(us, SQ_D1);
   }
 
       rto = relative_square(us, SQ_D1);
   }
 
-  assert(piece_on(kto) == king_of_color(us));
-  assert(piece_on(rto) == rook_of_color(us));
+  assert(piece_on(kto) == piece_of_color_and_type(us, KING));
+  assert(piece_on(rto) == piece_of_color_and_type(us, ROOK));
 
   // Remove pieces from destination squares
   clear_bit(&(byColorBB[us]), kto);
 
   // Remove pieces from destination squares
   clear_bit(&(byColorBB[us]), kto);
@@ -1452,7 +1452,7 @@ void Position::undo_ep_move(Move m) {
 
   assert(to == ep_square());
   assert(relative_rank(us, to) == RANK_6);
 
   assert(to == ep_square());
   assert(relative_rank(us, to) == RANK_6);
-  assert(piece_on(to) == pawn_of_color(us));
+  assert(piece_on(to) == piece_of_color_and_type(us, PAWN));
   assert(piece_on(from) == EMPTY);
   assert(piece_on(capsq) == EMPTY);
 
   assert(piece_on(from) == EMPTY);
   assert(piece_on(capsq) == EMPTY);