Skip to content

Commit

Permalink
Do not clean castling rights for Chess960 check
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Oct 7, 2015
1 parent e442a3b commit 8e5a4f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chess/__init__.py
Expand Up @@ -2489,6 +2489,9 @@ def has_queenside_castling_rights(self, color):
def has_chess960_castling_rights(self):
"""
Checks if there are castling rights that are only possible in Chess960.
The castling rights could still be invalid in the concrete position,
even in Chess960.
"""
# Standard chess castling rights can only be on the standard
# starting rook squares.
Expand All @@ -2497,9 +2500,9 @@ def has_chess960_castling_rights(self):

# If there are any castling rights in standard chess, the king must be
# on e1 or e8.
if self.has_castling_rights(WHITE) and not self.occupied_co[WHITE] & self.kings & BB_E1:
if self.castling_rights & BB_RANK_1 and not self.occupied_co[WHITE] & self.kings & BB_E1:
return True
if self.has_castling_rights(BLACK) and not self.occupied_co[BLACK] & self.kings & BB_E8:
if self.castling_rights & BB_RANK_8 and not self.occupied_co[BLACK] & self.kings & BB_E8:
return True

return False
Expand Down

0 comments on commit 8e5a4f9

Please sign in to comment.