From 8c518db51bd62d063aed57504ce54ba608524830 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 23 Jan 2023 05:13:12 +0300 Subject: fix: add pawn attacks to move generation --- src/board.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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 { 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 }); }; -- cgit v1.2.3