Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed generate_castling_moves to_mask bug #1036

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion chess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3610,11 +3610,13 @@ def generate_castling_moves(self, from_mask: Bitboard = BB_ALL, to_mask: Bitboar
bb_f = BB_FILE_F & backrank
bb_g = BB_FILE_G & backrank

for candidate in scan_reversed(self.clean_castling_rights() & backrank & to_mask):
for candidate in scan_reversed(self.clean_castling_rights() & backrank):
rook = BB_SQUARES[candidate]

a_side = rook < king
king_to = bb_c if a_side else bb_g
if not king_to & to_mask:
continue
rook_to = bb_d if a_side else bb_f

king_path = between(msb(king), msb(king_to))
Expand Down
Loading