os << "+\n";
}
- os << "\nFen: " << pos.fen() << "\nKey: " << std::hex << std::uppercase
+ os << "\nFen: " << pos.fen() << "\nSfen: " << pos.fen(true) << "\nKey: " << std::hex << std::uppercase
<< std::setfill('0') << std::setw(16) << pos.key()
<< std::setfill(' ') << std::dec << "\nCheckers: ";
/// Position::fen() returns a FEN representation of the position. In case of
/// Chess960 the Shredder-FEN notation is used. This is mainly a debugging function.
-const string Position::fen() const {
+const string Position::fen(bool sfen) const {
int emptyCnt;
std::ostringstream ss;
ss << '/';
}
+ // SFEN
+ if (sfen)
+ {
+ ss << (sideToMove == WHITE ? " b " : " w ");
+ for (Color c : {WHITE, BLACK})
+ for (PieceType pt = KING; pt >= PAWN; --pt)
+ ss << std::string(pieceCountInHand[c][pt], piece_to_char()[make_piece(c, pt)]);
+ if (!count_in_hand(WHITE, ALL_PIECES) && !count_in_hand(BLACK, ALL_PIECES))
+ ss << '-';
+ ss << " " << gamePly + 1;
+ return ss.str();
+ }
+
// pieces in hand
if (piece_drops() || gating())
{
// FEN string input/output
Position& set(const Variant* v, const std::string& fenStr, bool isChess960, StateInfo* si, Thread* th, bool sfen = false);
Position& set(const std::string& code, Color c, StateInfo* si);
- const std::string fen() const;
+ const std::string fen(bool sfen = false) const;
// Variant rule properties
const Variant* variant() const;