@@ -1586,10 +1586,10 @@ def generate_pseudo_legal_moves(self, from_mask=BB_ALL, to_mask=BB_ALL):
15861586 # Prepare pawn advance generation.
15871587 if self .turn == WHITE :
15881588 single_moves = pawns << 8 & ~ self .occupied
1589- double_moves = single_moves << 8 & ~ self .occupied & BB_RANK_4
1589+ double_moves = single_moves << 8 & ~ self .occupied & ( BB_RANK_3 | BB_RANK_4 )
15901590 else :
15911591 single_moves = pawns >> 8 & ~ self .occupied
1592- double_moves = single_moves >> 8 & ~ self .occupied & BB_RANK_5
1592+ double_moves = single_moves >> 8 & ~ self .occupied & ( BB_RANK_6 | BB_RANK_5 )
15931593
15941594 single_moves &= to_mask
15951595 double_moves &= to_mask
@@ -2148,9 +2148,9 @@ def push(self, move):
21482148
21492149 # Set en passant square.
21502150 if diff == 16 :
2151- if self . turn == WHITE :
2151+ if rank_index ( move . to_square ) == 3 :
21522152 self .ep_square = move .to_square - 8
2153- else :
2153+ elif rank_index ( move . to_square ) == 4 :
21542154 self .ep_square = move .to_square + 8
21552155
21562156 # Castling.
@@ -3358,10 +3358,10 @@ def generate_non_evasions(self, from_mask=BB_ALL, to_mask=BB_ALL):
33583358 # Prepare pawn advance generation.
33593359 if self .turn == WHITE :
33603360 single_moves = pawns << 8 & ~ self .occupied
3361- double_moves = single_moves << 8 & ~ self .occupied & BB_RANK_4
3361+ double_moves = single_moves << 8 & ~ self .occupied & ( BB_RANK_3 | BB_RANK_4 )
33623362 else :
33633363 single_moves = pawns >> 8 & ~ self .occupied
3364- double_moves = single_moves >> 8 & ~ self .occupied & BB_RANK_5
3364+ double_moves = single_moves >> 8 & ~ self .occupied & ( BB_RANK_6 | BB_RANK_5 )
33653365
33663366 single_moves &= to_mask
33673367 double_moves &= to_mask
@@ -3490,11 +3490,11 @@ def generate_evasions(self, from_mask=BB_ALL, to_mask=BB_ALL):
34903490
34913491 if self .turn == WHITE :
34923492 forward_pawns = our_pawns << 8 & BB_ALL
3493- double_forward_pawns = (our_pawns & BB_RANK_2 ) << 16 & BB_ALL
3493+ double_forward_pawns = (our_pawns & ( BB_RANK_1 | BB_RANK_2 ) ) << 16 & BB_ALL
34943494 last_double_mask = ep_square_mask >> 8 & self .pawns & self .occupied_co [BLACK ]
34953495 else :
34963496 forward_pawns = our_pawns >> 8
3497- double_forward_pawns = (our_pawns & BB_RANK_7 ) >> 16
3497+ double_forward_pawns = (our_pawns & ( BB_RANK_8 | BB_RANK_7 ) ) >> 16
34983498 last_double_mask = ep_square_mask << 8 & self .pawns & self .occupied_co [WHITE ]
34993499
35003500 if ep_square_mask & to_mask :
0 commit comments