// after the move is made
if (move_is_ep(m))
{
- Color us = side_to_move();
Color them = opposite_color(us);
- Square from = move_from(m);
Square to = move_to(m);
Square capsq = make_square(square_file(to), square_rank(from));
Square ksq = king_square(us);
}
-/// Position::move_is_legal() takes a position and a (not necessarily pseudo-legal)
-/// move and tests whether the move is legal. This version is not very fast and
-/// should be used only in non time-critical paths.
+/// Position::move_is_pl_slow() takes a position and a move and tests whether
+/// the move is pseudo legal. This version is not very fast and should be used
+/// only in non time-critical paths.
-bool Position::move_is_legal(const Move m) const {
+bool Position::move_is_pl_slow(const Move m) const {
MoveStack mlist[MAX_MOVES];
- MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
+ MoveStack *cur, *last;
+
+ last = in_check() ? generate<MV_EVASION>(*this, mlist)
+ : generate<MV_NON_EVASION>(*this, mlist);
- for (cur = mlist; cur != last; cur++)
+ for (cur = mlist; cur != last; cur++)
if (cur->move == m)
- return pl_move_is_legal(m, pinned_pieces(sideToMove));
+ return true;
return false;
}
-/// Fast version of Position::move_is_legal() that takes a position a move and
-/// a bitboard of pinned pieces as input, and tests whether the move is legal.
+/// Fast version of Position::move_is_pl() that takes a position a move and a
+/// bitboard of pinned pieces as input, and tests whether the move is pseudo legal.
-bool Position::move_is_legal(const Move m, Bitboard pinned) const {
+bool Position::move_is_pl(const Move m) const {
assert(is_ok());
- assert(pinned == pinned_pieces(sideToMove));
Color us = sideToMove;
Color them = opposite_color(sideToMove);
// Use a slower but simpler function for uncommon cases
if (move_is_special(m))
- return move_is_legal(m);
+ return move_is_pl_slow(m);
// Is not a promotion, so promotion piece must be empty
if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
}
}
- // The move is pseudo-legal, check if it is also legal
- return pl_move_is_legal(m, pinned);
+ return true;
}