Skip to content

Commit e4d8bbb

Browse files
committed
Refine battlekings gating attack handling
1 parent dca94e8 commit e4d8bbb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/position.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,8 +1277,9 @@ bool Position::legal(Move m) const {
12771277

12781278
Bitboard attackers = attackers_to(gating_square(m), occ, ~us);
12791279

1280-
// Ignore attacks from squares that will be cleared as part of the move
1281-
attackers &= ~SquareBB[to];
1280+
// Ignore attacks from enemy pieces that will be removed as part of the move
1281+
if (capture(m) && piece_on(to) != NO_PIECE)
1282+
attackers &= ~SquareBB[to];
12821283
if (type_of(m) == EN_PASSANT)
12831284
attackers &= ~SquareBB[capture_square(to)];
12841285

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def test_chess_promotion_does_not_gate(self):
435435
self.assertEqual(fen, "Q7/8/8/8/8/8/7p/7K b - - 0 1")
436436

437437
def test_battlekings_king_spawn_blocked(self):
438-
fen = "8/8/8/8/8/3p4/4Q3/8 w - - 0 1"
438+
fen = "8/8/8/8/8/4r3/4Q3/4r3 w - - 0 1"
439439
moves = sf.legal_moves("battlekings", fen, [])
440440
self.assertFalse(moves)
441441

0 commit comments

Comments
 (0)