[board] Rename BitBoard::has_piece_at → is_set
This commit is contained in:
parent
98fce9acde
commit
81d544f0d5
2 changed files with 7 additions and 7 deletions
|
@ -52,7 +52,7 @@ impl BitBoard {
|
|||
self.0 == 0
|
||||
}
|
||||
|
||||
pub fn has_piece_at(self, sq: Square) -> bool {
|
||||
pub fn is_set(self, sq: Square) -> bool {
|
||||
!(self & sq.into()).is_empty()
|
||||
}
|
||||
|
||||
|
@ -242,8 +242,8 @@ mod tests {
|
|||
#[test]
|
||||
fn has_piece_at() {
|
||||
let bb = BitBoard(0b1001100);
|
||||
assert!(bb.has_piece_at(Square::C1));
|
||||
assert!(!bb.has_piece_at(Square::B1));
|
||||
assert!(bb.is_set(Square::C1));
|
||||
assert!(!bb.is_set(Square::B1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -251,7 +251,7 @@ mod tests {
|
|||
let sq = Square::E4;
|
||||
let mut bb = BitBoard(0b1001100);
|
||||
bb.set_square(sq);
|
||||
assert!(bb.has_piece_at(sq));
|
||||
assert!(bb.is_set(sq));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -259,7 +259,7 @@ mod tests {
|
|||
let sq = Square::A3;
|
||||
let mut bb = BitBoard(0b1001100);
|
||||
bb.clear_square(sq);
|
||||
assert!(!bb.has_piece_at(sq));
|
||||
assert!(!bb.is_set(sq));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -137,7 +137,7 @@ impl Position {
|
|||
pub fn place_piece(&mut self, piece: Piece, square: Square) -> Result<(), PiecePlacementError> {
|
||||
let type_bb = self.bitboard_for_piece_mut(piece);
|
||||
|
||||
if type_bb.has_piece_at(square) {
|
||||
if type_bb.is_set(square) {
|
||||
return Err(PiecePlacementError::ExistsOnSquare);
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ impl Position {
|
|||
for shape in Shape::iter() {
|
||||
let piece = Piece::new(color, *shape);
|
||||
let bb = self.bitboard_for_piece(piece);
|
||||
if bb.has_piece_at(sq) {
|
||||
if bb.is_set(sq) {
|
||||
return Some(PlacedPiece::new(piece, sq));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue