X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=9af2d9d8103a62b43bc19343e78e64f23e586260;hp=eab1e0849005493a8b016256bf985395e1412d09;hb=9b1d5bd5343540db412c50ae2944246e3f25d18b;hpb=4d438fae9ec07f8cb7ba3efe33ca7309afce346f diff --git a/src/position.cpp b/src/position.cpp index eab1e084..9af2d9d8 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -56,6 +56,7 @@ struct PieceLetters : std::map { operator[]('B') = WB; operator[]('b') = BB; operator[]('N') = WN; operator[]('n') = BN; operator[]('P') = WP; operator[]('p') = BP; + operator[](' ') = EMPTY; operator[]('.') = EMPTY_BLACK_SQ; } char from_piece(Piece p) const { @@ -82,7 +83,6 @@ Key Position::zobExclusion; Score Position::PieceSquareTable[16][64]; -static bool RequestPending = false; static PieceLetters pieceLetters; @@ -372,44 +372,42 @@ const string Position::to_fen() const { /// Position::print() prints an ASCII representation of the position to /// the standard output. If a move is given then also the san is print. -void Position::print(Move m) const { +void Position::print(Move move) const { - static const string pieceLetters = " PNBRQK PNBRQK ."; + const char* dottedLine = "\n+---+---+---+---+---+---+---+---+\n"; + static bool requestPending = false; // Check for reentrancy, as example when called from inside // MovePicker that is used also here in move_to_san() - if (RequestPending) + if (requestPending) return; - RequestPending = true; + requestPending = true; - cout << endl; - if (m != MOVE_NONE) + if (move) { Position p(*this, thread()); - string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : ""); - cout << "Move is: " << col << move_to_san(p, m) << endl; + string dd = (color_of_piece_on(move_from(move)) == BLACK ? ".." : ""); + cout << "\nMove is: " << dd << move_to_san(p, move); } + for (Rank rank = RANK_8; rank >= RANK_1; rank--) { - cout << "+---+---+---+---+---+---+---+---+" << endl; + cout << dottedLine << '|'; for (File file = FILE_A; file <= FILE_H; file++) { Square sq = make_square(file, rank); + char c = (color_of_piece_on(sq) == BLACK ? '=' : ' '); Piece piece = piece_on(sq); - if (piece == EMPTY && square_color(sq) == WHITE) - piece = NO_PIECE; - char col = (color_of_piece_on(sq) == BLACK ? '=' : ' '); - cout << '|' << col << pieceLetters[piece] << col; + if (piece == EMPTY && same_color_squares(sq, SQ_A1)) + piece = EMPTY_BLACK_SQ; + + cout << c << pieceLetters.from_piece(piece) << c << '|'; } - cout << '|' << endl; } - cout << "+---+---+---+---+---+---+---+---+" << endl - << "Fen is: " << to_fen() << endl - << "Key is: " << st->key << endl; - - RequestPending = false; + cout << dottedLine << "Fen is: " << to_fen() << "\nKey is: " << st->key << endl; + requestPending = false; }