/// 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(bool sfen) const {
+const string Position::fen(bool sfen, std::string holdings) const {
int emptyCnt;
std::ostringstream ss;
if (piece_drops() || seirawan_gating())
{
ss << '[';
- 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 (holdings != "-")
+ ss << holdings;
+ else
+ 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)]);
ss << ']';
}
// 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(bool sfen = false) const;
+ const std::string fen(bool sfen = false, std::string holdings = "-") const;
// Variant rule properties
const Variant* variant() const;
go(pos, analysisLimits, states);
}
}
+ // Bughouse commands
+ else if (token == "partner") {} // ignore for now
+ else if (token == "ptell")
+ {
+ // TODO: parse requests by partner
+ }
+ else if (token == "holding")
+ {
+ // holding [<white>] [<black>] <color><piece>
+ std::string white_holdings, black_holdings;
+ if ( std::getline(is, token, '[') && std::getline(is, white_holdings, ']')
+ && std::getline(is, token, '[') && std::getline(is, black_holdings, ']'))
+ {
+ std::transform(black_holdings.begin(), black_holdings.end(), black_holdings.begin(), ::tolower);
+ std::string fen = pos.fen(false, white_holdings + black_holdings);
+ setboard(pos, states, fen);
+ }
+ }
// Additional custom non-XBoard commands
else if (token == "perft")
{