File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -244,17 +244,17 @@ impl Board {
244
244
245
245
/// Generate all possible moves at the specified square index
246
246
pub fn generate_moves ( & self , index : usize ) -> Vec < usize > {
247
- let mut moves = Vec :: new ( ) ;
248
-
249
247
let occupancy = self . white_occupancy . or ( & self . black_occupancy ) ;
250
248
251
- self . generate_pawn_moves ( & mut moves , occupancy, index) ;
249
+ let pawn_moves = self . generate_pawn_moves ( occupancy, index) ;
252
250
253
- moves
251
+ pawn_moves
254
252
}
255
253
256
254
/// Generate possible pawn moves at the specified square index
257
- fn generate_pawn_moves ( & self , moves : & mut Vec < usize > , occupancy : Bitboard , position : usize ) {
255
+ fn generate_pawn_moves ( & self , occupancy : Bitboard , position : usize ) -> Vec < usize > {
256
+ let mut moves = Vec :: new ( ) ;
257
+
258
258
let direction = match self . turn {
259
259
Color :: White => 8 ,
260
260
Color :: Black => -8 ,
@@ -280,5 +280,13 @@ impl Board {
280
280
if self . is_square_enemy ( self . turn , right_capture as usize ) {
281
281
moves. push ( right_capture as usize ) ;
282
282
}
283
+
284
+ if let Some ( square) = self . en_passant_square {
285
+ if self . is_square_enemy ( self . turn , square as usize ) {
286
+ moves. push ( square as usize ) ;
287
+ }
288
+ }
289
+
290
+ moves
283
291
}
284
292
}
You can’t perform that action at this time.
0 commit comments