diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-23 05:13:12 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-23 05:13:12 +0300 |
commit | 8c518db51bd62d063aed57504ce54ba608524830 (patch) | |
tree | 21f524cc25aaccac917a79f76e3191f41905e71f /src/board.rs | |
parent | 9a41a379a8a1f33b6a9d28f1d5ff3c1d0826e1f5 (diff) | |
download | chessnost-8c518db51bd62d063aed57504ce54ba608524830.tar.gz |
fix: add pawn attacks to move generation
Diffstat (limited to 'src/board.rs')
-rw-r--r-- | src/board.rs | 6 |
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 }); }; |