X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=ff0c4162a8f4e77303be946d4b68e171b304f6dc;hp=1bae3620087ff62edb5268ca6902617fb2745f25;hb=f3e0b32def471a698e855061aa8e728657248a0f;hpb=188700d7f15a778919ac65268adfee57c870dcda 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)