MoKy

FSF_EnPassant

Aug 7th, 2025 (edited)
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. # Fixed en passant for custom pieces with identical move/capture patterns in Fairy Stockfish
  2. # https://github.com/fairy-stockfish/Fairy-Stockfish/blob/master/src/movegen.cpp
  3. # Line 310: Remove '& ~quiets' from epSquares calculation
  4. # Line 304: Add '& ~epSquares' to b1 to prevent duplicate moves
  5. # Place Line 310 before Line 304
  6.  
  7.   template<Color Us, GenType Type>
  8.   ExtMove* generate_moves(const Position& pos, ExtMove* moveList, PieceType Pt, Bitboard target) {
  9.  
  10.     assert(Pt != KING && Pt != PAWN);
  11.  
  12.     Bitboard bb = pos.pieces(Us, Pt);
  13.  
  14.     while (bb)
  15.     {
  16.         Square from = pop_lsb(bb);
  17.  
  18.         Bitboard attacks = pos.attacks_from(Us, Pt, from);
  19.         Bitboard quiets = pos.moves_from(Us, Pt, from);
  20.         Bitboard b = ((attacks & pos.pieces()) | (quiets & ~pos.pieces()));
  21.  
  22.         Bitboard epSquares = pos.variant()->enPassantTypes[Us] & Pt ? attacks & pos.ep_squares() & ~pos.pieces() : Bitboard(0);
  23.         Bitboard b1 = b & target & ~epSquares;
  24.  
  25.         Bitboard promotion_zone = pos.promotion_zone(Us);
  26.         PieceType promPt = pos.promoted_piece_type(Pt);
  27.         Bitboard b2 = promPt && (!pos.promotion_limit(promPt) || pos.promotion_limit(promPt) > pos.count(Us, promPt)) ? b1 : Bitboard(0);
  28.         Bitboard b3 = pos.piece_demotion() && pos.is_promoted(from) ? b1 : Bitboard(0);
  29.         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