mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 08:36:33 +08:00
Teach file_to_char() about upper/lower case
This allows to further simplify Position::fen() No functional change.
This commit is contained in:
@@ -358,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 << '-';
|
||||
|
||||
@@ -441,8 +441,8 @@ inline int square_distance(Square s1, Square s2) {
|
||||
return SquareDistance[s1][s2];
|
||||
}
|
||||
|
||||
inline char file_to_char(File f) {
|
||||
return char(f - FILE_A + 'a');
|
||||
inline char file_to_char(File f, bool tolower = true) {
|
||||
return char(f - FILE_A + (tolower ? 'a' : 'A'));
|
||||
}
|
||||
|
||||
inline char rank_to_char(Rank r) {
|
||||
|
||||
Reference in New Issue
Block a user