- // En passant captures are a tricky special case. Because they are rather
- // uncommon, we do it simply by testing whether the king is attacked after
- // the move is made.
- if (type_of(m) == ENPASSANT)
- {
- Square ksq = square<KING>(us);
- Square capsq = to - pawn_push(us);
- Bitboard occupied = (pieces() ^ from ^ capsq) | to;
-
- assert(to == ep_square());
- assert(moved_piece(m) == make_piece(us, PAWN));
- assert(piece_on(capsq) == make_piece(~us, PAWN));
- assert(piece_on(to) == NO_PIECE);
-
- return !(attacks_bb< ROOK>(ksq, occupied) & pieces(~us, QUEEN, ROOK))
- && !(attacks_bb<BISHOP>(ksq, occupied) & pieces(~us, QUEEN, BISHOP));
- }
+ // st->previous->blockersForKing consider capsq as empty.
+ // If pinned, it has to move along the king ray.
+ if (type_of(m) == EN_PASSANT)
+ return !(st->previous->blockersForKing[sideToMove] & from)
+ || aligned(from, to, square<KING>(us));