/// generate_checks() generates all pseudo-legal non-capturing, non-promoting
/// checks. It returns the number of generated moves.
/// generate_checks() generates all pseudo-legal non-capturing, non-promoting
/// checks. It returns the number of generated moves.
MoveStack* mlist_start = mlist;
assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));
MoveStack* mlist_start = mlist;
assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));
/// in check. Unlike the other move generation functions, this one generates
/// only legal moves. It returns the number of generated moves.
/// in check. Unlike the other move generation functions, this one generates
/// only legal moves. It returns the number of generated moves.
// Generate pseudo-legal moves
int n = generate_captures(pos, mlist);
// Generate pseudo-legal moves
int n = generate_captures(pos, mlist);
/// returned. If not, the function returns false. This function must
/// only be used when the side to move is not in check.
/// returned. If not, the function returns false. This function must
/// only be used when the side to move is not in check.
Color us = pos.side_to_move();
Color them = opposite_color(us);
Square from = move_from(m);
Piece pc = pos.piece_on(from);
Color us = pos.side_to_move();
Color them = opposite_color(us);
Square from = move_from(m);
Piece pc = pos.piece_on(from);
// If the from square is not occupied by a piece belonging to the side to
// move, the move is obviously not legal.
// If the from square is not occupied by a piece belonging to the side to
// move, the move is obviously not legal.
assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN));
// The move is pseudo-legal, check if it is also legal
assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN));
// The move is pseudo-legal, check if it is also legal
}
// Luckly we can handle all the other pieces in one go
return ( pos.piece_attacks_square(pos.piece_on(from), from, to)
}
// Luckly we can handle all the other pieces in one go
return ( pos.piece_attacks_square(pos.piece_on(from), from, to)