]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Use MoveList also in Position::move_is_pl_slow()
[stockfish] / src / position.cpp
index 7490953dbe3dd16a2034303bde978fe00ad4c10d..7f0e1447d08bde86e81ee24781a260509e0da54c 100644 (file)
@@ -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<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;
@@ -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)