return Us == WHITE ? p << 9 : p >> 7;
else if (Direction == DELTA_NW)
return Us == WHITE ? p << 7 : p >> 9;
-
- assert(false);
- return p;
+ else
+ return p;
}
// Template generate_piece_checks() with specializations
}
-/// generate_checks() generates all pseudo-legal non-capturing, non-promoting
-/// checks. It returns the number of generated moves.
+/// generate_non_capture_checks() generates all pseudo-legal non-capturing,
+/// non-promoting checks. It returns the number of generated moves.
-int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
+int generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
assert(pos.is_ok());
assert(!pos.is_check());
// Proceed according to the type of the moving piece.
if (type_of_piece(pc) == PAWN)
{
+ // Move direction must be compatible with pawn color
+ int direction = to - from;
+ if ((us == WHITE) != (direction > 0))
+ return false;
+
// If the destination square is on the 8/1th rank, the move must
// be a promotion.
if ( ( (square_rank(to) == RANK_8 && us == WHITE)
// Proceed according to the square delta between the source and
// destionation squares.
- switch (to - from)
+ switch (direction)
{
case DELTA_NW:
case DELTA_NE:
return mlist;
Bitboard checkSqs = pos.piece_attacks<Piece>(ksq) & pos.empty_squares();
+ if (!checkSqs)
+ return mlist;
+
while (b)
{
Square from = pop_1st_bit(&b);
+ if ( (Piece == QUEEN && !(QueenPseudoAttacks[from] & checkSqs))
+ || (Piece == ROOK && !(RookPseudoAttacks[from] & checkSqs))
+ || (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
+ continue;
+
Bitboard bb = pos.piece_attacks<Piece>(from) & checkSqs;
SERIALIZE_MOVES(bb);
}