From 35bdd377ccdf7da6ac46653439e6b5ab72953b76 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Mon, 27 Sep 2021 21:41:51 +0200 Subject: [PATCH] Limit pawn moves to variant board size Closes #372. --- setup.py | 2 +- src/movegen.cpp | 2 +- src/pyffish.cpp | 2 +- test.py | 5 +++++ tests/perft.sh | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 72422ee..f964dff 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ pyffish_module = Extension( sources=sources, extra_compile_args=args) -setup(name="pyffish", version="0.0.61", +setup(name="pyffish", version="0.0.62", description="Fairy-Stockfish Python wrapper", long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/movegen.cpp b/src/movegen.cpp index 4daa190..7d11d74 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -115,7 +115,7 @@ namespace { Bitboard TRank3BB = forward_ranks_bb(Us, relative_rank(Us, pos.double_step_rank_min(), pos.max_rank())) & ~shift(forward_ranks_bb(Us, relative_rank(Us, pos.double_step_rank_max(), pos.max_rank()))); - const Bitboard emptySquares = Type == QUIETS || Type == QUIET_CHECKS ? target : ~pos.pieces(); + const Bitboard emptySquares = Type == QUIETS || Type == QUIET_CHECKS ? target : ~pos.pieces() & pos.board_bb(); const Bitboard enemies = Type == EVASIONS ? (pos.checkers() & pos.non_sliding_riders() ? pos.pieces(Them) : pos.checkers()) : Type == CAPTURES ? target : pos.pieces(Them); diff --git a/src/pyffish.cpp b/src/pyffish.cpp index 3462beb..7551385 100644 --- a/src/pyffish.cpp +++ b/src/pyffish.cpp @@ -54,7 +54,7 @@ void buildPosition(Position& pos, StateListPtr& states, const char *variant, con } extern "C" PyObject* pyffish_version(PyObject* self) { - return Py_BuildValue("(iii)", 0, 0, 61); + return Py_BuildValue("(iii)", 0, 0, 62); } extern "C" PyObject* pyffish_info(PyObject* self) { diff --git a/test.py b/test.py index 2dc7f5b..d2696a5 100644 --- a/test.py +++ b/test.py @@ -647,6 +647,11 @@ class TestPyffish(unittest.TestCase): result = sf.is_optional_game_end("capablanca", CAPA, []) self.assertFalse(result[0]) + # sittuyin stalemate due to optional promotion + result = sf.is_optional_game_end("sittuyin", "1k4PK/3r4/8/8/8/8/8/8[] w - - 0 1", []) + self.assertTrue(result[0]) + self.assertEqual(result[1], sf.VALUE_DRAW) + def test_has_insufficient_material(self): for variant, positions in variant_positions.items(): for fen, expected_result in positions.items(): diff --git a/tests/perft.sh b/tests/perft.sh index 946f88a..5f2ae0d 100755 --- a/tests/perft.sh +++ b/tests/perft.sh @@ -50,6 +50,7 @@ if [[ $1 == "all" || $1 == "variant" ]]; then expect perft.exp sittuyin "fen 8/8/6R1/s3r3/P5R1/1KP3p1/1F2kr2/8[] b - - 0 72" 4 652686 > /dev/null expect perft.exp sittuyin "fen 2r5/6k1/6p1/3s2P1/3npR2/8/p2N2F1/3K4[] w - - 1 50" 4 373984 > /dev/null expect perft.exp sittuyin "fen 8/6s1/5P2/3n4/pR2K2S/1P6/1k4p1/8[] w - - 1 50" 4 268869 > /dev/null + expect perft.exp sittuyin "fen 1k5K/3r2P1/8/8/8/8/8/8[] w - - 0 1" 5 68662 > /dev/null expect perft.exp shatranj startpos 4 68122 > /dev/null expect perft.exp amazon startpos 4 318185 > /dev/null expect perft.exp nightrider startpos 4 419019 > /dev/null -- 1.7.0.4