-
-
Notifications
You must be signed in to change notification settings - Fork 559
Introduce Board._effective_promoted() #1180
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -127,16 +127,8 @@ def is_legal(self, move: chess.Move) -> bool: | |||||
| else: | ||||||
| return not any(self.generate_pseudo_legal_captures()) | ||||||
|
|
||||||
| def _transposition_key(self) -> Hashable: | ||||||
| if self.has_chess960_castling_rights(): | ||||||
| return (super()._transposition_key(), self.kings & self.promoted) | ||||||
| else: | ||||||
| return super()._transposition_key() | ||||||
|
|
||||||
| def board_fen(self, *, promoted: Optional[bool] = None) -> str: | ||||||
| if promoted is None: | ||||||
| promoted = self.has_chess960_castling_rights() | ||||||
| return super().board_fen(promoted=promoted) | ||||||
| def _effective_promoted(self) -> chess.Bitboard: | ||||||
| return self.kings & self.promoted if self.castling_rights else chess.BB_EMPTY | ||||||
|
||||||
| return self.kings & self.promoted if self.castling_rights else chess.BB_EMPTY | |
| return self.kings & self.promoted if self.clean_castling_rights() else chess.BB_EMPTY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
board_fen()recomputespromoted_mask(and may call_effective_promoted()) inside the per-square loop. Sincepromoteddoes not change while building the string, computepromoted_maskonce before iterating squares to avoid repeated work in this hot path.