Skip to content

Commit

Permalink
Condense CrazyhouseBoard.is_pseudo_legal()
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Feb 16, 2019
1 parent 102ca5d commit 0023e3f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions chess/variant.py
Expand Up @@ -721,16 +721,11 @@ def legal_drop_squares(self):

def is_pseudo_legal(self, move):
if move.drop and move.from_square == move.to_square:
if move.drop == chess.KING:
return False

if chess.BB_SQUARES[move.to_square] & self.occupied:
return False

if move.drop == chess.PAWN and chess.BB_SQUARES[move.to_square] & chess.BB_BACKRANKS:
return False

return self.pockets[self.turn].count(move.drop) > 0
return (
move.drop != chess.KING and
not chess.BB_SQUARES[move.to_square] & self.occupied and
not (move.drop == chess.PAWN and chess.BB_SQUARES[move.to_square] & chess.BB_BACKRANKS) and
self.pockets[self.turn].count(move.drop) > 0)
else:
return super().is_pseudo_legal(move)

Expand Down

0 comments on commit 0023e3f

Please sign in to comment.