From: Marco Costalba Date: Sat, 29 Jan 2011 12:14:01 +0000 (+0100) Subject: Do not use in to_fen() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=f3e0b32def471a698e855061aa8e728657248a0f;ds=sidebyside Do not use in to_fen() Seems there are some problems on HP-UX compiler. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/position.cpp b/src/position.cpp index 1bae3620..ff0c4162 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -17,7 +17,6 @@ along with this program. If not, see . */ -#include #include #include #include @@ -77,8 +76,6 @@ namespace { // Bonus for having the side to move (modified by Joona Kiiski) const Score TempoValue = make_score(48, 22); - bool isZero(char c) { return c == '0'; } - struct PieceLetters : public std::map { PieceLetters() { @@ -341,7 +338,7 @@ const string Position::to_fen() const { Square sq; char emptyCnt = '0'; - for (Rank rank = RANK_8; rank >= RANK_1; rank--) + for (Rank rank = RANK_8; rank >= RANK_1; rank--, fen += '/') { for (File file = FILE_A; file <= FILE_H; file++) { @@ -349,19 +346,23 @@ const string Position::to_fen() const { if (square_is_occupied(sq)) { - fen += emptyCnt; + if (emptyCnt != '0') + { + fen += emptyCnt; + emptyCnt = '0'; + } fen += pieceLetters.from_piece(piece_on(sq)); - emptyCnt = '0'; } else emptyCnt++; } - fen += emptyCnt; - fen += '/'; - emptyCnt = '0'; + + if (emptyCnt != '0') + { + fen += emptyCnt; + emptyCnt = '0'; + } } - fen.erase(std::remove_if(fen.begin(), fen.end(), isZero), fen.end()); - fen.erase(--fen.end()); fen += (sideToMove == WHITE ? " w " : " b "); if (st->castleRights != CASTLES_NONE)