From: Ada Joule Date: Sun, 13 Feb 2022 14:46:27 +0000 (+0700) Subject: Atomic check exception (#440) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ac9e95c82a1c11ecfc8162d82ad1dc0d7bfdd473;p=fairystockfish.git Atomic check exception (#440) --- diff --git a/src/position.cpp b/src/position.cpp index d1a1c1f..81de344 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -923,8 +923,13 @@ Bitboard Position::attackers_to(Square s, Bitboard occupied) const { Bitboard Position::attackers_to_pseudo_royals(Color c) const { Bitboard attackers = 0; Bitboard pseudoRoyals = st->pseudoRoyals & pieces(~c); + Bitboard pseudoRoyalsTheirs = st->pseudoRoyals & pieces(c); while (pseudoRoyals) { Square sr = pop_lsb(pseudoRoyals); + if (blast_on_capture() + && pseudoRoyalsTheirs & attacks_bb(sr)) + // skip if capturing this piece would blast all of the attacker's pseudo-royal pieces + continue; attackers |= attackers_to(sr, c); } return attackers; diff --git a/test.py b/test.py index 837847c..2996862 100644 --- a/test.py +++ b/test.py @@ -725,6 +725,9 @@ class TestPyffish(unittest.TestCase): result = sf.gives_check("atomic", "rnbqkbnr/ppp2ppp/8/8/8/8/PPP2PPP/RNBQKBNR w KQkq - 0 4", ["d1d7"]) self.assertTrue(result) + result = sf.gives_check("atomic", "8/8/kK6/8/8/8/Q7/8 b - - 0 1", []) + self.assertFalse(result) + def test_game_result(self): result = sf.game_result("chess", CHESS, ["f2f3", "e7e5", "g2g4", "d8h4"]) self.assertEqual(result, -sf.VALUE_MATE) diff --git a/tests/js/test.js b/tests/js/test.js index 6b26297..d7598b6 100644 --- a/tests/js/test.js +++ b/tests/js/test.js @@ -484,6 +484,8 @@ describe('board.isCheck()', function () { board.setFen("rnbqkbnr/ppp2ppp/8/8/8/8/PPP2PPP/RNBQKBNR w KQkq - 0 4"); board.pushSan("Qd7"); chai.expect(board.isCheck()).to.equal(true); + board.setFen("8/8/kK6/8/8/8/Q7/8 b - - 0 1") + chai.expect(board.isCheck()).to.equal(false); board.delete(); }); });