}
-/// Position::move_is_pl_slow() takes 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.
+/// Position::move_is_legal() takes a move and tests whether the move
+/// is legal. This version is not very fast and should be used only
+/// in non time-critical paths.
-bool Position::move_is_pl_slow(const Move m) const {
+bool Position::move_is_legal(const Move m) const {
- MoveStack mlist[MAX_MOVES];
- MoveStack *cur, *last;
-
- last = in_check() ? generate<MV_EVASION>(*this, mlist)
- : generate<MV_NON_EVASION>(*this, mlist);
-
- for (cur = mlist; cur != last; cur++)
- if (cur->move == m)
+ for (MoveList<MV_LEGAL> ml(*this); !ml.end(); ++ml)
+ if (ml.move() == m)
return true;
return false;
// Use a slower but simpler function for uncommon cases
if (move_is_special(m))
- return move_is_pl_slow(m);
+ return move_is_legal(m);
// Is not a promotion, so promotion piece must be empty
if (promotion_piece_type(m) - 2 != PIECE_TYPE_NONE)
bool Position::is_mate() const {
- MoveStack moves[MAX_MOVES];
- return in_check() && generate<MV_LEGAL>(*this, moves) == moves;
+ return in_check() && !MoveList<MV_LEGAL>(*this).size();
}