]> git.sesse.net Git - stockfish/commitdiff
Add checkers info to Position::pretty()
authorMarco Costalba <mcostalba@gmail.com>
Wed, 26 Dec 2012 17:22:56 +0000 (18:22 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 26 Dec 2012 17:28:45 +0000 (18:28 +0100)
In case current position is under check, list the
squares of the checker(s) pieces.

This should satisfy a specific user request.

No functional change.

src/position.cpp

index e69528ad0c628a2aca423d0d2575386dc75390db..de5d04c13ac8982368fcd10edf0eab96168058ec 100644 (file)
@@ -400,14 +400,21 @@ const string Position::pretty(Move move) const {
   std::ostringstream ss;
 
   if (move)
-      ss << "\nMove is: " << (sideToMove == BLACK ? ".." : "")
+      ss << "\nMove: " << (sideToMove == BLACK ? ".." : "")
          << move_to_san(*const_cast<Position*>(this), move);
 
   for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
       if (piece_on(sq) != NO_PIECE)
           brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)];
 
-  ss << brd << "\nFen is: " << fen() << "\nKey is: " << st->key;
+  ss << brd << "\nFen: " << fen() << "\nKey: " << st->key;
+
+  if (checkers())
+  {
+      ss << "\nCheckers: ";
+      for (Bitboard b = checkers(); b; )
+          ss << square_to_string(pop_lsb(&b)) << " ";
+  }
   return ss.str();
 }