X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=7f0e1447d08bde86e81ee24781a260509e0da54c;hp=7490953dbe3dd16a2034303bde978fe00ad4c10d;hb=155bed18f5224d401ddf5b4b71d93d8a8c379b3c;hpb=95d9687d95e5aa540c58e673300ef911164c90e0 diff --git a/src/position.cpp b/src/position.cpp index 7490953d..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)