Use MoveList also in Position::move_is_pl_slow()

And rename it in Position::move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-07-03 10:38:20 +01:00
parent 95d9687d95
commit 155bed18f5
4 changed files with 19 additions and 24 deletions

View 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)