aboutsummaryrefslogtreecommitdiff
path: root/src/board.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/board.rs')
-rw-r--r--src/board.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/board.rs b/src/board.rs
index 55086bf..a078fff 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -100,13 +100,21 @@ impl Board {
!self.occupancy
}
- fn color_occupancy(&self, color: Color) -> Bitboard {
- let mut occupancy = 0;
+ fn pieces_by_color(&self, color: Color) -> [Bitboard; 6] {
+ let mut pieces = [0; 6];
for (piece_type, piece) in self.pieces.iter().enumerate() {
if piece_type % 2 == color as usize {
- occupancy |= piece;
+ pieces[piece_type / 2] = *piece;
}
}
+ pieces
+ }
+
+ fn color_occupancy(&self, color: Color) -> Bitboard {
+ let mut occupancy = 0;
+ for piece in self.pieces_by_color(color) {
+ occupancy |= piece;
+ }
occupancy
}