]> git.sesse.net Git - stockfish/commitdiff
Teach file_to_char() about upper/lower case
authorMarco Costalba <mcostalba@gmail.com>
Fri, 4 Jan 2013 13:10:35 +0000 (14:10 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 4 Jan 2013 13:45:04 +0000 (14:45 +0100)
This allows to further simplify Position::fen()

No functional change.

src/position.cpp
src/types.h

index 8dab668bd90e1fb392338e7d933e6e6aa5647d96..a005d5df2809e069318f0bbb7fec1c67d04ffea9 100644 (file)
@@ -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 << '-';
index 506e1b0f9b5f1adeb6c82db127d89b5165432ec4..b7bcb4e89f168c9fdf48cdad1fcfc9d596712ccd 100644 (file)
@@ -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) {