#include "movegen.h"
#include "position.h"
+namespace Stockfish {
+
namespace {
template<GenType Type, Direction D>
Bitboard pawnsOn7 = pos.pieces(Us, PAWN) & TRank7BB;
Bitboard pawnsNotOn7 = pos.pieces(Us, PAWN) & ~TRank7BB;
- Bitboard enemies = (Type == EVASIONS ? pos.pieces(Them) & target:
+ Bitboard enemies = (Type == EVASIONS ? pos.checkers():
Type == CAPTURES ? target : pos.pieces(Them));
// Single and double pawn pushes, no promotions
{
assert(rank_of(pos.ep_square()) == relative_rank(Us, RANK_6));
- // An en passant capture cannot resolve a discovered check.
+ // An en passant capture cannot resolve a discovered check
if (Type == EVASIONS && (target & (pos.ep_square() + Up)))
return moveList;
Bitboard bb = piecesToMove & pos.pieces(Pt);
- if (!bb)
- return moveList;
-
- [[maybe_unused]] const Bitboard checkSquares = pos.check_squares(Pt);
-
while (bb) {
Square from = pop_lsb(&bb);
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
if constexpr (Checks)
- b &= checkSquares;
+ b &= pos.check_squares(Pt);
while (b)
*moveList++ = make_move(from, pop_lsb(&b));
target = ~pos.pieces();
break;
case EVASIONS:
- {
- Square checksq = lsb(pos.checkers());
- target = between_bb(pos.square<KING>(Us), checksq) | checksq;
+ target = between_bb(pos.square<KING>(Us), lsb(pos.checkers()));
break;
- }
case NON_EVASIONS:
target = ~pos.pieces(Us);
break;
if (more_than_one(pos.checkers()))
return moveList; // Double check, only a king move can save the day
- // Generate blocking evasions or captures of the checking piece
+ // Generate blocking interpositions or captures of the checking piece
return us == WHITE ? generate_all<WHITE, EVASIONS>(pos, moveList)
: generate_all<BLACK, EVASIONS>(pos, moveList);
}
return moveList;
}
+
+} // namespace Stockfish