X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=a005d5df2809e069318f0bbb7fec1c67d04ffea9;hb=e83b9075ffc2efb72a3008e9261e575c66eb3d06;hp=de5d04c13ac8982368fcd10edf0eab96168058ec;hpb=e9ab7353de074a0a970d334ac98b391e2222f77d;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index de5d04c1..a005d5df 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -331,33 +331,26 @@ void Position::set_castle_right(Color c, Square rfrom) { const string Position::fen() const { std::ostringstream ss; - Square sq; - int emptyCnt; for (Rank rank = RANK_8; rank >= RANK_1; rank--) { - emptyCnt = 0; - for (File file = FILE_A; file <= FILE_H; file++) { - sq = file | rank; + Square sq = file | rank; if (is_empty(sq)) - emptyCnt++; - else { - if (emptyCnt > 0) - { - ss << emptyCnt; - emptyCnt = 0; - } - ss << PieceToChar[piece_on(sq)]; + int emptyCnt = 1; + + for ( ; file < FILE_H && is_empty(sq++); file++) + emptyCnt++; + + ss << emptyCnt; } + else + ss << PieceToChar[piece_on(sq)]; } - if (emptyCnt > 0) - ss << emptyCnt; - if (rank > RANK_1) ss << '/'; } @@ -365,16 +358,16 @@ const string Position::fen() const { ss << (sideToMove == WHITE ? " w " : " b "); if (can_castle(WHITE_OO)) - ss << (chess960 ? char(toupper(file_to_char(file_of(castle_rook_square(WHITE, KING_SIDE))))) : 'K'); + ss << (chess960 ? file_to_char(file_of(castle_rook_square(WHITE, KING_SIDE)), false) : 'K'); if (can_castle(WHITE_OOO)) - ss << (chess960 ? char(toupper(file_to_char(file_of(castle_rook_square(WHITE, QUEEN_SIDE))))) : 'Q'); + ss << (chess960 ? file_to_char(file_of(castle_rook_square(WHITE, QUEEN_SIDE)), false) : 'Q'); if (can_castle(BLACK_OO)) - ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK, KING_SIDE))) : 'k'); + ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK, KING_SIDE)), true) : 'k'); if (can_castle(BLACK_OOO)) - ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK, QUEEN_SIDE))) : 'q'); + ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK, QUEEN_SIDE)), true) : 'q'); if (st->castleRights == CASTLES_NONE) ss << '-'; @@ -407,14 +400,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 ml(*this); !ml.end(); ++ml) + ss << move_to_san(*const_cast(this), ml.move()) << " "; - if (checkers()) - { - ss << "\nCheckers: "; - for (Bitboard b = checkers(); b; ) - ss << square_to_string(pop_lsb(&b)) << " "; - } return ss.str(); }