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 {
244244
245245 /// Generate all possible moves at the specified square index
246246 pub fn generate_moves ( & self , index : usize ) -> Vec < usize > {
247- let mut moves = Vec :: new ( ) ;
248-
249247 let occupancy = self . white_occupancy . or ( & self . black_occupancy ) ;
250248
251- self . generate_pawn_moves ( & mut moves , occupancy, index) ;
249+ let pawn_moves = self . generate_pawn_moves ( occupancy, index) ;
252250
253- moves
251+ pawn_moves
254252 }
255253
256254 /// 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+
258258 let direction = match self . turn {
259259 Color :: White => 8 ,
260260 Color :: Black => -8 ,
@@ -280,5 +280,13 @@ impl Board {
280280 if self . is_square_enemy ( self . turn , right_capture as usize ) {
281281 moves. push ( right_capture as usize ) ;
282282 }
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
283291 }
284292}
You can’t perform that action at this time.
0 commit comments