From 208b35121f9dab4c60c82813b051eeabc9d502cd Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 23 Jan 2023 08:41:29 +0300 Subject: fix: consider blocking pieces when double pushing --- src/board.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/board.rs b/src/board.rs index 54efab9..625711e 100644 --- a/src/board.rs +++ b/src/board.rs @@ -152,8 +152,14 @@ impl Board { for target in serialize_bitboard(self.attacks.pawn[color as usize][source as usize] & opponent_occupancy) { moves.push(Move { source, target }); }; + } + for source in serialize_bitboard(*piece) { for target in serialize_bitboard(self.attacks.pawn_pushes[color as usize][source as usize] & available_targets) { - moves.push(Move { source, target }); + // Exclude double pushes in a monkey way + // TODO: properly rewrite this storing a separate bitboard for double pushes + if !((source as u8 / 8 == 1) && (target as u8 / 8 == 3) && (self.occupancy & (1 << (source as u8 + 8)) > 0)) { + moves.push(Move { source, target }); + } }; } } -- cgit v1.2.3