From a4c63f19e54bc6d381f4dd8eaedebd0f65132245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Varga=20D=C3=A1vid=20Lajos?= Date: Wed, 19 Nov 2025 20:52:28 +0100 Subject: [PATCH] implemented move generation method for pawn capture moves --- engine/src/bitboard/movegen/pawns.rs | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/engine/src/bitboard/movegen/pawns.rs b/engine/src/bitboard/movegen/pawns.rs index 30d2000..3cb7037 100644 --- a/engine/src/bitboard/movegen/pawns.rs +++ b/engine/src/bitboard/movegen/pawns.rs @@ -35,4 +35,40 @@ impl Board { } } } + fn add_pawn_captures(&self, buffer: &mut MoveBuffer, move_mask: u64) { + let offset = 6 * self.side_to_move as usize; + let mut pawns: u64 = self.bitboards[offset]; + let opponents = self.occupancy[1 - self.side_to_move as usize]; + while pawns != 0 { + let next_sq: u32 = pawns.trailing_zeros(); + pawns &= !(1 << next_sq); + + let mut attacks: u64 = self.get_pseudo_pawn_captures(next_sq) & move_mask; + attacks = self.get_pin_masked_moves(attacks, next_sq); + attacks &= opponents; + + while attacks != 0 { + let to_sq = attacks.trailing_zeros(); + + if (self.side_to_move == 0 && attacks.trailing_zeros() / 8 == 7) + || (self.side_to_move == 1 && attacks.trailing_zeros() / 8 == 0) { + for piece_type in [3, 2, 1, 0] { + buffer.add(BitMove::capture( + next_sq as u8, + to_sq as u8, + Some(piece_type) + )); + } + } + else { + buffer.add(BitMove::capture( + next_sq as u8, + to_sq as u8, + None + )); + } + attacks &= !(1 << to_sq); + } + } + } } \ No newline at end of file