sources=sources,
extra_compile_args=args)
-setup(name="pyffish", version="0.0.73",
+setup(name="pyffish", version="0.0.74",
description="Fairy-Stockfish Python wrapper",
long_description=long_description,
long_description_content_type="text/markdown",
Board::sfInitialized = true;
}
+ bool captures_to_hand(std::string uciVariant) {
+ const Variant* v = get_variant(uciVariant);
+ return v->capturesToHand;
+ }
+
std::string starting_fen(std::string uciVariant) {
const Variant* v = get_variant(uciVariant);
return v->startFen;
function("readGamePGN", &read_game_pgn);
function("variants", &ffish::available_variants);
function("loadVariantConfig", &ffish::load_variant_config);
+ function("capturesToHand", &ffish::captures_to_hand);
function("startingFen", &ffish::starting_fen);
function("validateFen", select_overload<int(std::string)>(&ffish::validate_fen));
function("validateFen", select_overload<int(std::string, std::string)>(&ffish::validate_fen));
}
extern "C" PyObject* pyffish_version(PyObject* self) {
- return Py_BuildValue("(iii)", 0, 0, 73);
+ return Py_BuildValue("(iii)", 0, 0, 74);
}
extern "C" PyObject* pyffish_info(PyObject* self) {
return Py_BuildValue("O", variants.find(std::string(variant))->second->twoBoards ? Py_True : Py_False);
}
+// INPUT variant
+extern "C" PyObject* pyffish_capturesToHand(PyObject* self, PyObject *args) {
+ const char *variant;
+
+ if (!PyArg_ParseTuple(args, "s", &variant)) {
+ return NULL;
+ }
+
+ return Py_BuildValue("O", variants.find(std::string(variant))->second->capturesToHand ? Py_True : Py_False);
+}
+
// INPUT variant, fen, move
extern "C" PyObject* pyffish_getSAN(PyObject* self, PyObject *args) {
PyObject* moveList = PyList_New(0);
{"load_variant_config", (PyCFunction)pyffish_loadVariantConfig, METH_VARARGS, "Load variant configuration."},
{"start_fen", (PyCFunction)pyffish_startFen, METH_VARARGS, "Get starting position FEN."},
{"two_boards", (PyCFunction)pyffish_twoBoards, METH_VARARGS, "Checks whether the variant is played on two boards."},
+ {"captures_to_hand", (PyCFunction)pyffish_capturesToHand, METH_VARARGS, "Checks whether the variant rules contains capturesToHand."},
{"get_san", (PyCFunction)pyffish_getSAN, METH_VARARGS, "Get SAN move from given FEN and UCI move."},
{"get_san_moves", (PyCFunction)pyffish_getSANmoves, METH_VARARGS, "Get SAN movelist from given FEN and UCI movelist."},
{"legal_moves", (PyCFunction)pyffish_legalMoves, METH_VARARGS, "Get legal moves from given FEN and movelist."},
self.assertFalse(sf.two_boards("chess"))
self.assertTrue(sf.two_boards("bughouse"))
+ def test_captures_to_hand(self):
+ self.assertFalse(sf.captures_to_hand("seirawan"))
+ self.assertTrue(sf.captures_to_hand("shouse"))
+
def test_start_fen(self):
result = sf.start_fen("capablanca")
self.assertEqual(result, CAPA)
});
});
+describe('ffish.capturesToHand(uciVariant)', function () {
+ it("it checks if the given uci-variant rules contain capturesToHand", () => {
+ chai.expect(ffish.capturesToHand("seirawan")).to.equal(false);
+ chai.expect(ffish.capturesToHand("shouse")).to.equal(true);
+ });
+});
+
describe('ffish.startingFen(uciVariant)', function () {
it("it returns the starting fen for the given uci-variant.", () => {
chai.expect(ffish.startingFen("chess")).to.equal("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");