aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-23 08:41:29 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-23 08:41:42 +0300
commit208b35121f9dab4c60c82813b051eeabc9d502cd (patch)
treedabc422466cf034df34aa5d46824cdeb466bf94a
parent06185b5b7f5d9f1d5d57627f86e286879be92e6e (diff)
downloadchessnost-208b35121f9dab4c60c82813b051eeabc9d502cd.tar.gz
fix: consider blocking pieces when double pushing
-rw-r--r--src/board.rs8
1 files changed, 7 insertions, 1 deletions
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 });
+ }
};
}
}