diff --git a/board/src/bitboard.rs b/board/src/bitboard.rs index f799e4c..5b17050 100644 --- a/board/src/bitboard.rs +++ b/board/src/bitboard.rs @@ -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")]