/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal
-bool Position::pl_move_is_legal(Move m) const {
-
- // If we're in check, all pseudo-legal moves are legal, because our
- // check evasion generator only generates true legal moves.
- return is_check() || pl_move_is_legal(m, pinned_pieces(side_to_move()));
-}
-
bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
assert(is_ok());
assert(move_is_ok(m));
assert(pinned == pinned_pieces(side_to_move()));
- assert(!is_check());
// Castling moves are checked for legality during move generation.
if (move_is_castle(m))
assert(color_of_piece_on(from) == us);
assert(piece_on(king_square(us)) == piece_of_color_and_type(us, KING));
- // En passant captures are a tricky special case. Because they are
+ // En passant captures are a tricky special case. Because they are
// rather uncommon, we do it simply by testing whether the king is attacked
// after the move is made
if (move_is_ep(m))
Piece capture = piece_on(to);
Bitboard occ = occupied_squares();
+ // King cannot be recaptured
+ if (type_of_piece(piece) == KING)
+ return seeValues[capture];
+
// Handle en passant moves
if (st->epSquare == to && type_of_piece_on(from) == PAWN)
{
for (int i = 0; i < 64; i++)
board[i] = EMPTY;
- for (int i = 0; i < 7; i++)
- for (int j = 0; j < 8; j++)
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 16; j++)
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
sideToMove = WHITE;
bool Position::is_mate() const {
MoveStack moves[256];
-
- return is_check() && (generate_evasions(*this, moves, pinned_pieces(sideToMove)) == moves);
+ return is_check() && (generate_moves(*this, moves, false) == moves);
}