Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Fixed en passant for custom pieces with identical move/capture patterns in Fairy Stockfish
- # https://github.com/fairy-stockfish/Fairy-Stockfish/blob/master/src/movegen.cpp
- # Line 310: Remove '& ~quiets' from epSquares calculation
- # Line 304: Add '& ~epSquares' to b1 to prevent duplicate moves
- # Place Line 310 before Line 304
- template<Color Us, GenType Type>
- ExtMove* generate_moves(const Position& pos, ExtMove* moveList, PieceType Pt, Bitboard target) {
- assert(Pt != KING && Pt != PAWN);
- Bitboard bb = pos.pieces(Us, Pt);
- while (bb)
- {
- Square from = pop_lsb(bb);
- Bitboard attacks = pos.attacks_from(Us, Pt, from);
- Bitboard quiets = pos.moves_from(Us, Pt, from);
- Bitboard b = ((attacks & pos.pieces()) | (quiets & ~pos.pieces()));
- Bitboard epSquares = pos.variant()->enPassantTypes[Us] & Pt ? attacks & pos.ep_squares() & ~pos.pieces() : Bitboard(0);
- Bitboard b1 = b & target & ~epSquares;
- Bitboard promotion_zone = pos.promotion_zone(Us);
- PieceType promPt = pos.promoted_piece_type(Pt);
- Bitboard b2 = promPt && (!pos.promotion_limit(promPt) || pos.promotion_limit(promPt) > pos.count(Us, promPt)) ? b1 : Bitboard(0);
- Bitboard b3 = pos.piece_demotion() && pos.is_promoted(from) ? b1 : Bitboard(0);
- Bitboard pawnPromotions = pos.variant()->promotionPawnTypes[Us] & Pt ? b & (Type == EVASIONS ? target : ~pos.pieces(Us)) & promotion_zone : Bitboard(0);
Advertisement
Add Comment
Please, Sign In to add comment