[board] Add remove_piece_at() method to BitBoard
This commit is contained in:
parent
ed9a919db6
commit
aa7e901241
1 changed files with 17 additions and 2 deletions
|
@ -19,6 +19,10 @@ impl BitBoard {
|
|||
self.0 |= 1 << sq.index
|
||||
}
|
||||
|
||||
fn remove_piece_at(&mut self, sq: &Square) {
|
||||
self.0 &= !(1 << sq.index)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
fn _arm_count_leading_zeros(&self) -> u8 {
|
||||
let mut number_of_leading_zeros: u8 = 0;
|
||||
|
@ -58,9 +62,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn place_piece_at() {
|
||||
let sq = Square::from_index(34).expect("Invalid square index");
|
||||
|
||||
let mut bb = BitBoard(0b1001100);
|
||||
bb.place_piece_at(&Square::from_index(34).expect("Invalid square index"));
|
||||
assert!(bb.has_piece_at(&Square::from_index(34).expect("Invalid square index")));
|
||||
bb.place_piece_at(&sq);
|
||||
assert!(bb.has_piece_at(&sq));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_piece_at() {
|
||||
let sq = Square::from_index(2).expect("Invalid square index");
|
||||
|
||||
let mut bb = BitBoard(0b1001100);
|
||||
bb.remove_piece_at(&sq);
|
||||
assert!(!bb.has_piece_at(&sq));
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue