]> git.sesse.net Git - stockfish/commitdiff
Add list of legal moves to Position::pretty()
authorMarco Costalba <mcostalba@gmail.com>
Thu, 27 Dec 2012 10:08:20 +0000 (11:08 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 27 Dec 2012 10:34:48 +0000 (11:34 +0100)
Along the same lines of previous patch now we add
the list of the legal moves in the given position.

No functional change.

src/position.cpp

index de5d04c13ac8982368fcd10edf0eab96168058ec..c814e7657a7e8505d557ff77c673e03889d580c4 100644 (file)
@@ -407,14 +407,15 @@ const string Position::pretty(Move move) const {
       if (piece_on(sq) != NO_PIECE)
           brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)];
 
-  ss << brd << "\nFen: " << fen() << "\nKey: " << st->key;
+  ss << brd << "\nFen: " << fen() << "\nKey: " << st->key << "\nCheckers: ";
+
+  for (Bitboard b = checkers(); b; )
+      ss << square_to_string(pop_lsb(&b)) << " ";
+
+  ss << "\nLegal moves: ";
+  for (MoveList<LEGAL> ml(*this); !ml.end(); ++ml)
+      ss << move_to_san(*const_cast<Position*>(this), ml.move()) << " ";
 
-  if (checkers())
-  {
-      ss << "\nCheckers: ";
-      for (Bitboard b = checkers(); b; )
-          ss << square_to_string(pop_lsb(&b)) << " ";
-  }
   return ss.str();
 }