aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/board.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/board.rs b/src/board.rs
index 9df26fe..ca526b7 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -141,11 +141,15 @@ impl Board {
pub fn generate_moves(&self, color: Color) -> Vec<Move> {
let mut moves = Vec::with_capacity(1024);
- let available_targets = self.color_occupancy(Color::from(1 - color as u8)) | self.empty();
+ let opponent_occupancy = self.color_occupancy(Color::from(1 - color as u8));
+ let available_targets = opponent_occupancy | self.empty();
for (piece_type, piece) in self.pieces_by_color(color).iter().enumerate() {
match PieceType::from(piece_type) {
PieceType::Pawn => {
for source in serialize_bitboard(*piece) {
+ for target in serialize_bitboard(self.attacks.pawn[color as usize][source as usize] & opponent_occupancy) {
+ moves.push(Move { source, target });
+ };
for target in serialize_bitboard(self.attacks.pawn_pushes[color as usize][source as usize] & available_targets) {
moves.push(Move { source, target });
};