From 3d8c0f16c237b1fddaec75c5db70545da47e8bcc Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 1 Mar 2014 22:07:41 +0100 Subject: [PATCH] Rename xxx_to_char() -> to_char() No functional change. --- src/notation.cpp | 12 ++++++------ src/position.cpp | 12 ++++++------ src/types.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/notation.cpp b/src/notation.cpp index a57072ef..3ca43deb 100644 --- a/src/notation.cpp +++ b/src/notation.cpp @@ -72,7 +72,7 @@ const string move_to_uci(Move m, bool chess960) { if (type_of(m) == CASTLING && !chess960) to = (to > from ? FILE_G : FILE_C) | rank_of(from); - string move = square_to_string(from) + square_to_string(to); + string move = to_string(from) + to_string(to); if (type_of(m) == PROMOTION) move += PieceToChar[BLACK][promotion_type(m)]; // Lower case @@ -140,22 +140,22 @@ const string move_to_san(Position& pos, Move m) { if (others) { if (!(others & file_bb(from))) - san += file_to_char(file_of(from)); + san += to_char(file_of(from)); else if (!(others & rank_bb(from))) - san += rank_to_char(rank_of(from)); + san += to_char(rank_of(from)); else - san += square_to_string(from); + san += to_string(from); } } else if (pos.capture(m)) - san = file_to_char(file_of(from)); + san = to_char(file_of(from)); if (pos.capture(m)) san += 'x'; - san += square_to_string(to); + san += to_string(to); if (type_of(m) == PROMOTION) san += string("=") + PieceToChar[WHITE][promotion_type(m)]; diff --git a/src/position.cpp b/src/position.cpp index 78fccbb2..0cea2d37 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -353,21 +353,21 @@ const string Position::fen() const { ss << (sideToMove == WHITE ? " w " : " b "); if (can_castle(WHITE_OO)) - ss << (chess960 ? file_to_char(file_of(castling_rook_square(WHITE, KING_SIDE)), false) : 'K'); + ss << (chess960 ? to_char(file_of(castling_rook_square(WHITE, KING_SIDE)), false) : 'K'); if (can_castle(WHITE_OOO)) - ss << (chess960 ? file_to_char(file_of(castling_rook_square(WHITE, QUEEN_SIDE)), false) : 'Q'); + ss << (chess960 ? to_char(file_of(castling_rook_square(WHITE, QUEEN_SIDE)), false) : 'Q'); if (can_castle(BLACK_OO)) - ss << (chess960 ? file_to_char(file_of(castling_rook_square(BLACK, KING_SIDE)), true) : 'k'); + ss << (chess960 ? to_char(file_of(castling_rook_square(BLACK, KING_SIDE)), true) : 'k'); if (can_castle(BLACK_OOO)) - ss << (chess960 ? file_to_char(file_of(castling_rook_square(BLACK, QUEEN_SIDE)), true) : 'q'); + ss << (chess960 ? to_char(file_of(castling_rook_square(BLACK, QUEEN_SIDE)), true) : 'q'); if (!can_castle(WHITE) && !can_castle(BLACK)) ss << '-'; - ss << (ep_square() == SQ_NONE ? " - " : " " + square_to_string(ep_square()) + " ") + ss << (ep_square() == SQ_NONE ? " - " : " " + to_string(ep_square()) + " ") << st->rule50 << " " << 1 + (gamePly - int(sideToMove == BLACK)) / 2; return ss.str(); @@ -401,7 +401,7 @@ const string Position::pretty(Move move) const { << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: "; for (Bitboard b = checkers(); b; ) - ss << square_to_string(pop_lsb(&b)) << " "; + ss << to_string(pop_lsb(&b)) << " "; ss << "\nLegal moves: "; for (MoveList it(*this); *it; ++it) diff --git a/src/types.h b/src/types.h index 03053591..2317626e 100644 --- a/src/types.h +++ b/src/types.h @@ -391,11 +391,11 @@ inline bool opposite_colors(Square s1, Square s2) { return ((s >> 3) ^ s) & 1; } -inline char file_to_char(File f, bool tolower = true) { +inline char to_char(File f, bool tolower = true) { return char(f - FILE_A + (tolower ? 'a' : 'A')); } -inline char rank_to_char(Rank r) { +inline char to_char(Rank r) { return char(r - RANK_1 + '1'); } @@ -434,8 +434,8 @@ inline bool is_ok(Move m) { #include -inline const std::string square_to_string(Square s) { - char ch[] = { file_to_char(file_of(s)), rank_to_char(rank_of(s)), 0 }; +inline const std::string to_string(Square s) { + char ch[] = { to_char(file_of(s)), to_char(rank_of(s)), 0 }; return ch; } -- 2.39.2