[board, position] Implement some methods to check for whether a king is in check
Remove some dead code from Position.
This commit is contained in:
parent
0abe9b6c19
commit
b8a51990a3
3 changed files with 50 additions and 17 deletions
|
@ -122,23 +122,6 @@ impl Position {
|
|||
self.moves().moves_for_piece(piece)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn is_king_in_check(&self) -> bool {
|
||||
let danger_squares = self.king_danger(self.player_to_move());
|
||||
!(danger_squares & self.king_bitboard(self.player_to_move())).is_empty()
|
||||
}
|
||||
|
||||
fn king_bitboard(&self, player: Color) -> BitBoard {
|
||||
self.board.pieces.bitboard_for_piece(Piece::king(player))
|
||||
}
|
||||
|
||||
pub(crate) fn king_square(&self, player: Color) -> Square {
|
||||
self.king_bitboard(player)
|
||||
.occupied_squares(&IterationDirection::default())
|
||||
.next()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn checking_pieces(&self) -> CheckingPieces {
|
||||
let opponent = self.player_to_move().other();
|
||||
let king_square = self.king_square(self.player_to_move());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue