[position] Address a few warnings in Position
Build Position::sight_of_piece() and ::is_king_in_check() for cfg(test) only. Expand the doc comment for ::king_danger() slightly. Remove an unused Rank import. # Conflicts: # position/src/position/position.rs
This commit is contained in:
parent
e94819c79a
commit
1958c1a50e
1 changed files with 5 additions and 1 deletions
|
@ -212,12 +212,15 @@ impl Position {
|
|||
self.moves().moves_for_piece(piece)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn sight_of_piece(&self, piece: &PlacedPiece) -> BitBoard {
|
||||
piece.sight(&self.pieces, self.en_passant_square)
|
||||
}
|
||||
|
||||
/// A bitboard representing the squares where a king of the given color will
|
||||
/// be in danger. The king cannot move to these squares.
|
||||
/// be in danger of being captured by the opposing player. If the king is on
|
||||
/// one of these squares, it is in check. The king cannot move to these
|
||||
/// squares.
|
||||
pub(crate) fn king_danger(&self, color: Color) -> BitBoard {
|
||||
let pieces_without_king = {
|
||||
let mut cloned_pieces = self.pieces.clone();
|
||||
|
@ -230,6 +233,7 @@ impl Position {
|
|||
self._sight_of_player(color.other(), &pieces_without_king)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn is_king_in_check(&self) -> bool {
|
||||
let danger_squares = self.king_danger(self.color_to_move);
|
||||
!(danger_squares & self.king_bitboard(self.color_to_move)).is_empty()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue