Skip to content

Commit 3e4dcaa

Browse files
committed
Fix a bogus assert in allows()
Becuase castle is coded as "king captures the rook" the to_sq(move), A1/8 or H1/8 is empty after the move, leading to assert assert(p != NO_PIECE) in color_of(). Teach allows() asserts about castle and fix the crash. Bug reported by Ryan Takker and tracked down by Tom Vijlbrief. No functional change.
1 parent 14f47c8 commit 3e4dcaa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/search.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ namespace {
14001400
assert(is_ok(first));
14011401
assert(is_ok(second));
14021402
assert(color_of(pos.piece_on(from_sq(second))) == ~pos.side_to_move());
1403-
assert(color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
1403+
assert(type_of(first) == CASTLE || color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
14041404

14051405
Square m1from = from_sq(first);
14061406
Square m2from = from_sq(second);

0 commit comments

Comments
 (0)