X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=7f0e1447d08bde86e81ee24781a260509e0da54c;hb=155bed18f5224d401ddf5b4b71d93d8a8c379b3c;hp=1e01dc1f7298f5ece888713fb3edcdf3fd215910;hpb=3f806df0ca753e834da1b78e309d676ddf867463;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index 1e01dc1f..7f0e1447 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -545,20 +545,14 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { } -/// 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(*this, mlist) - : generate(*this, mlist); - - for (cur = mlist; cur != last; cur++) - if (cur->move == m) + for (MoveList ml(*this); !ml.end(); ++ml) + if (ml.move() == m) return true; return false; @@ -580,7 +574,7 @@ bool Position::move_is_pl(const Move m) const { // 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) @@ -1724,8 +1718,7 @@ template bool Position::is_draw() const; bool Position::is_mate() const { - MoveStack moves[MAX_MOVES]; - return in_check() && generate(*this, moves) == moves; + return in_check() && !MoveList(*this).size(); }