X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=d43554d18e20fd9ff14a52014ee2a5dbcf086dd6;hp=4f72d6588ef3c3f4e6cdf8e60e3206a8cba7de10;hb=5644e14d0e3d69b3f845e475771564ffb3e25445;hpb=d07a8753983d0cbe7d81e61136b304e771b57ba7 diff --git a/src/position.cpp b/src/position.cpp index 4f72d658..d43554d1 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -108,6 +108,30 @@ CheckInfo::CheckInfo(const Position& pos) { } +/// operator<<(Position) returns an ASCII representation of the position + +std::ostream& operator<<(std::ostream& os, const Position& pos) { + + os << "\n +---+---+---+---+---+---+---+---+\n"; + + for (Rank r = RANK_8; r >= RANK_1; --r) + { + for (File f = FILE_A; f <= FILE_H; ++f) + os << " | " << PieceToChar[pos.piece_on(make_square(f, r))]; + + os << " |\n +---+---+---+---+---+---+---+---+\n"; + } + + os << "\nFen: " << pos.fen() << "\nKey: " << std::hex << std::uppercase + << std::setfill('0') << std::setw(16) << pos.st->key << "\nCheckers: "; + + for (Bitboard b = pos.checkers(); b; ) + os << UCI::format_square(pop_lsb(&b)) << " "; + + return os; +} + + /// Position::init() initializes at startup the various arrays used to compute /// hash keys and the piece square tables. The latter is a two-step operation: /// Firstly, the white halves of the tables are copied from PSQT[] tables. @@ -430,32 +454,6 @@ const string Position::fen() const { } -/// Position::pretty() returns an ASCII representation of the position - -const string Position::pretty() const { - - std::ostringstream ss; - - ss << "\n +---+---+---+---+---+---+---+---+\n"; - - for (Rank r = RANK_8; r >= RANK_1; --r) - { - for (File f = FILE_A; f <= FILE_H; ++f) - ss << " | " << PieceToChar[piece_on(make_square(f, r))]; - - ss << " |\n +---+---+---+---+---+---+---+---+\n"; - } - - ss << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase - << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: "; - - for (Bitboard b = checkers(); b; ) - ss << UCI::format_square(pop_lsb(&b)) << " "; - - return ss.str(); -} - - /// Position::game_phase() calculates the game phase interpolating total non-pawn /// material between endgame and midgame limits.