return this->pos.fen();
}
+ std::string fen(bool showPromoted, int countStarted) const {
+ return this->pos.fen(false, showPromoted, countStarted);
+ }
+
void set_fen(std::string fen) {
resetStates();
moveStack.clear();
.function("pop", &Board::pop)
.function("reset", &Board::reset)
.function("is960", &Board::is_960)
- .function("fen", &Board::fen)
+ .function("fen", select_overload<std::string()const>(&Board::fen))
+ .function("fen", select_overload<std::string(bool, int)const>(&Board::fen))
.function("setFen", &Board::set_fen)
.function("sanMove", select_overload<std::string(std::string)>(&Board::san_move))
.function("sanMove", select_overload<std::string(std::string, Notation)>(&Board::san_move))
}
inline int Position::counting_ply(int countStarted) const {
- return countStarted == 0 || (count<ALL_PIECES>(WHITE) <= 1 || count<ALL_PIECES>(BLACK) <= 1) ? st->countingPly : std::min(st->countingPly, std::max(1 + gamePly - countStarted, 0));
+ return countStarted == 0 || (count<ALL_PIECES>(WHITE) <= 1 || count<ALL_PIECES>(BLACK) <= 1) ? st->countingPly : countStarted < 0 ? 0 : std::min(st->countingPly, std::max(1 + gamePly - countStarted, 0));
}
inline int Position::rule50_count() const {
if (!PyArg_ParseTuple(args, "ssO!|pppi", &variant, &fen, &PyList_Type, &moveList, &chess960, &sfen, &showPromoted, &countStarted)) {
return NULL;
}
- countStarted = std::min<unsigned int>(countStarted, INT_MAX); // pseudo-unsigned
StateListPtr states(new std::deque<StateInfo>(1));
buildPosition(pos, states, variant, fen, moveList, chess960);
if (!PyArg_ParseTuple(args, "ssO!|pi", &variant, &fen, &PyList_Type, &moveList, &chess960, &countStarted)) {
return NULL;
}
- countStarted = std::min<unsigned int>(countStarted, INT_MAX); // pseudo-unsigned
StateListPtr states(new std::deque<StateInfo>(1));
buildPosition(pos, states, variant, fen, moveList, chess960);
});
});
+describe('board.fen(showPromoted, countStarted)', function () {
+ it("it returns the current position in fen format. showPromoted makes promoted pieces always followed by the symbol ~ regardless of variant. countStarted overwrites the start of makruk's board honor counting.", () => {
+ let board = new ffish.Board("makruk", "8/6ks/3M~2r1/2K1M3/8/3R4/8/8 w - 128 18 50");
+ chai.expect(board.fen(true, 0)).to.equal("8/6ks/3M~2r1/2K1M3/8/3R4/8/8 w - 128 18 50");
+ chai.expect(board.fen(true, -1)).to.equal("8/6ks/3M~2r1/2K1M3/8/3R4/8/8 w - 128 0 50");
+ chai.expect(board.fen(true, 89)).to.equal("8/6ks/3M~2r1/2K1M3/8/3R4/8/8 w - 128 10 50");
+ });
+});
+
describe('board.setFen(fen)', function () {
it("it sets a custom position via fen", () => {
let board = new ffish.Board();