// Single and double pawn pushes, no promotions
if (Type != CAPTURES)
{
- emptySquares = (Type == QUIETS || Type == QUIET_CHECKS ? target : ~pos.pieces());
+ emptySquares = (Type == QUIETS || Type == QUIET_CHECKS ? target : ~pos.pieces() & pos.board_bb());
Bitboard b1 = shift<Up>(pawnsNotOn7) & emptySquares;
Bitboard b2 = pos.double_step_enabled() ? shift<Up>(b1 & TRank3BB) & emptySquares : Bitboard(0);
if (pawnsOn7)
{
if (Type == CAPTURES)
- emptySquares = ~pos.pieces();
+ emptySquares = ~pos.pieces() & pos.board_bb();
if (Type == EVASIONS)
emptySquares &= target;
{
if (pos.count(Us, pt))
continue;
- Bitboard b = (pos.attacks_from(Us, pt, from) & ~pos.pieces()) | from;
+ Bitboard b = (pos.attacks_from(Us, pt, from) & ~pos.pieces() & pos.board_bb()) | from;
if (Type == EVASIONS)
b &= target;
if (pt == PAWN)
continue; // Will be generated together with direct checks
- Bitboard b = pos.moves_from(us, pt, from) & ~pos.pieces();
+ Bitboard b = pos.moves_from(us, pt, from) & ~pos.pieces() & pos.board_bb();
if (pt == KING)
b &= ~PseudoAttacks[~us][QUEEN][pos.square<KING>(~us)];
}
// Generate evasions for king, capture and non capture moves
- Bitboard b = pos.attacks_from<KING>(us, ksq) & ~pos.pieces(us) & ~sliderAttacks;
+ Bitboard b = pos.attacks_from<KING>(us, ksq) & ~pos.pieces(us) & ~sliderAttacks & pos.board_bb();
while (b)
moveList = make_move_and_gating<NORMAL>(pos, moveList, us, ksq, pop_lsb(&b));
assert(color_of(moved_piece(m)) == us);
assert(!count<KING>(us) || piece_on(square<KING>(us)) == make_piece(us, KING));
- // Illegal moves to squares outside of board
- if (!(board_bb() & to))
- return false;
-
// Illegal checks
if ((!checking_permitted() || (sittuyin_promotion() && type_of(m) == PROMOTION)) && gives_check(m))
return false;
Square to = to_sq(m);
Piece pc = moved_piece(m);
+ // Illegal moves to squares outside of board
+ if (!(board_bb() & to))
+ return false;
+
// Use a fast check for piece drops
if (type_of(m) == DROP)
return piece_drops()