[bitboard,core,position] Address a bunch of clippy warnings
This commit is contained in:
parent
d0abbd8f93
commit
27a36565f3
8 changed files with 63 additions and 32 deletions
|
@ -1,10 +1,9 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use crate::sight::SliderRayToSquareExt;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::Shape;
|
||||
|
||||
use crate::sight::SliderRayToSquareExt;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct CheckingPieces {
|
||||
bitboards: [BitBoard; 5],
|
||||
|
@ -23,12 +22,12 @@ impl CheckingPieces {
|
|||
}
|
||||
}
|
||||
|
||||
/// The number of checking pieces.
|
||||
pub fn count(&self) -> u32 {
|
||||
self.bitboards.iter().map(BitBoard::population_count).sum()
|
||||
}
|
||||
|
||||
/// A BitBoard representing the set of pieces that must be captured to
|
||||
/// resolve check.
|
||||
/// A BitBoard representing the set of pieces that must be captured to resolve check.
|
||||
pub fn capture_mask(&self) -> BitBoard {
|
||||
if self.count() == 0 {
|
||||
BitBoard::FULL
|
||||
|
@ -39,8 +38,8 @@ impl CheckingPieces {
|
|||
}
|
||||
}
|
||||
|
||||
/// A BitBoard representing the set of squares to which a player can move a
|
||||
/// piece to block a checking piece.
|
||||
/// A BitBoard representing the set of squares to which a player can move a piece to block a
|
||||
/// checking piece.
|
||||
pub fn push_mask(&self, king: &BitBoard) -> BitBoard {
|
||||
let target = king.first_occupied_square().unwrap();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ impl PieceBitBoards {
|
|||
}
|
||||
|
||||
pub(super) fn place_piece(&mut self, piece: &PlacedPiece) -> Result<(), PlacePieceError> {
|
||||
self.place_piece_with_strategy(piece, Default::default())
|
||||
self.place_piece_with_strategy(piece, PlacePieceStrategy::default())
|
||||
}
|
||||
|
||||
pub(super) fn place_piece_with_strategy(
|
||||
|
|
|
@ -138,22 +138,27 @@ impl Position {
|
|||
})
|
||||
}
|
||||
|
||||
/// Return a BitBoard representing the set of squares containing a piece.
|
||||
/// A [BitBoard] representing the set of squares containing a piece.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn occupied_squares(&self) -> &BitBoard {
|
||||
&self.pieces.all_pieces()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn friendly_pieces(&self) -> &BitBoard {
|
||||
self.pieces.all_pieces_of_color(self.color_to_move)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn opposing_pieces(&self) -> &BitBoard {
|
||||
self.pieces.all_pieces_of_color(self.color_to_move.other())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn all_pieces(&self) -> (&BitBoard, &BitBoard) {
|
||||
(self.friendly_pieces(), self.opposing_pieces())
|
||||
}
|
||||
|
@ -161,6 +166,7 @@ impl Position {
|
|||
/// Return a BitBoard representing the set of squares containing a piece.
|
||||
/// This set is the inverse of `occupied_squares`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn empty_squares(&self) -> BitBoard {
|
||||
!self.occupied_squares()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue