Skip to content

Commit b2338d2

Browse files
committed
Block castling when rook is frozen by potion
1 parent 9ba933b commit b2338d2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/position.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,9 @@ bool Position::legal(Move m) const {
13471347

13481348
// Will the gate be blocked by king or rook?
13491349
Square rto = to + (to_sq(m) > from_sq(m) ? WEST : EAST);
1350-
if (is_gating(m) && (gating_square(m) == to || gating_square(m) == rto))
1350+
if (is_gating(m) && (gating_square(m) == to || gating_square(m) == rto))
1351+
return false;
1352+
if (freeze_squares() & to_sq(m))
13511353
return false;
13521354

13531355
// Non-royal pieces can not be impeded from castling

tests/perft.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ if [[ $1 == "all" || $1 == "variant" ]]; then
156156
expect perft.exp atomic "fen 1R4kr/4K3/8/8/8/8/8/8 b k - 0 1" 4 17915 true > /dev/null
157157
expect perft.exp extinction "fen rnbqb1kr/pppppppp/8/8/8/8/PPPPPPPP/RNBQB1KR w AHah - 0 1" 4 195286 true > /dev/null
158158
expect perft.exp seirawan "fen qbbrnkrn/pppppppp/8/8/8/8/PPPPPPPP/QBBRNKRN[HEhe] w ABCDEFGHabcdefgh - 0 1" 3 21170 true > /dev/null
159+
expect perft.exp spell-chess "fen 4k3/p7/8/8/8/8/8/4K2R[f] b K - 0 1 moves f@h1,a7a6" 1 5 > /dev/null
159160
fi
160161

161162
# large-board variants

0 commit comments

Comments
 (0)