1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Do not use <algorithm> in to_fen()

Seems there are some problems on HP-UX compiler.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-01-29 13:14:01 +01:00
parent 188700d7f1
commit f3e0b32def

View file

@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <algorithm>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
@ -77,8 +76,6 @@ namespace {
// Bonus for having the side to move (modified by Joona Kiiski) // Bonus for having the side to move (modified by Joona Kiiski)
const Score TempoValue = make_score(48, 22); const Score TempoValue = make_score(48, 22);
bool isZero(char c) { return c == '0'; }
struct PieceLetters : public std::map<char, Piece> { struct PieceLetters : public std::map<char, Piece> {
PieceLetters() { PieceLetters() {
@ -341,7 +338,7 @@ const string Position::to_fen() const {
Square sq; Square sq;
char emptyCnt = '0'; 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++) for (File file = FILE_A; file <= FILE_H; file++)
{ {
@ -349,19 +346,23 @@ const string Position::to_fen() const {
if (square_is_occupied(sq)) if (square_is_occupied(sq))
{ {
fen += emptyCnt; if (emptyCnt != '0')
{
fen += emptyCnt;
emptyCnt = '0';
}
fen += pieceLetters.from_piece(piece_on(sq)); fen += pieceLetters.from_piece(piece_on(sq));
emptyCnt = '0';
} else } else
emptyCnt++; emptyCnt++;
} }
fen += emptyCnt;
fen += '/'; if (emptyCnt != '0')
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 "); fen += (sideToMove == WHITE ? " w " : " b ");
if (st->castleRights != CASTLES_NONE) if (st->castleRights != CASTLES_NONE)