From: Marco Costalba Date: Thu, 19 Feb 2009 15:48:57 +0000 (+0100) Subject: Do not pass pinned argument in Position::pl_move_is_legal() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=734941672ee239636d4327525243c39261a9b171 Do not pass pinned argument in Position::pl_move_is_legal() No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/movegen.cpp b/src/movegen.cpp index 94bc173e..39030572 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -360,7 +360,7 @@ int generate_legal_moves(const Position& pos, MoveStack* mlist) { // Remove illegal moves from the list for (int i = 0; i < n; i++) - if (!pos.pl_move_is_legal(mlist[i].move, pinned)) + if (!pos.pl_move_is_legal(mlist[i].move)) mlist[i--].move = mlist[--n].move; return n; @@ -405,7 +405,7 @@ bool move_is_legal(const Position& pos, const Move m) { assert(pos.piece_on(to - pawn_push(us)) == piece_of_color_and_type(them, PAWN)); // The move is pseudo-legal, check if it is also legal - return pos.pl_move_is_legal(m, pinned); + return pos.pl_move_is_legal(m); } // Castling moves @@ -537,12 +537,12 @@ bool move_is_legal(const Position& pos, const Move m) { return false; } // The move is pseudo-legal, check if it is also legal - return pos.pl_move_is_legal(m, pinned); + return pos.pl_move_is_legal(m); } // Luckly we can handle all the other pieces in one go return ( pos.piece_attacks_square(pos.piece_on(from), from, to) - && pos.pl_move_is_legal(m, pinned) + && pos.pl_move_is_legal(m) && !move_promotion(m)); } diff --git a/src/movepick.cpp b/src/movepick.cpp index c90f8df1..4c75b0fe 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -394,7 +394,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move, pinned)) + && pos.pl_move_is_legal(move)) return move; } break; @@ -414,7 +414,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move, pinned)) + && pos.pl_move_is_legal(move)) return move; } break; @@ -442,7 +442,7 @@ Move MovePicker::pick_move_from_list() { move = badCaptures[movesPicked++].move; if ( move != ttMove && move != mateKiller - && pos.pl_move_is_legal(move, pinned)) + && pos.pl_move_is_legal(move)) return move; } break; @@ -457,7 +457,7 @@ Move MovePicker::pick_move_from_list() { moves[bestIndex] = moves[movesPicked++]; // Remember to change the line below if we decide to hash the qsearch! // Maybe also postpone the legality check until after futility pruning? - if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) + if (/* move != ttMove && */ pos.pl_move_is_legal(move)) return move; } break; @@ -471,7 +471,7 @@ Move MovePicker::pick_move_from_list() { { move = moves[movesPicked++].move; // Remember to change the line below if we decide to hash the qsearch! - if (/* move != ttMove && */ pos.pl_move_is_legal(move, pinned)) + if (/* move != ttMove && */ pos.pl_move_is_legal(move)) return move; } break; diff --git a/src/position.cpp b/src/position.cpp index a999b4c6..3bb8fef9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -478,22 +478,12 @@ void Position::find_checkers() { } -/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal. -/// There are two versions of this function: One which takes only a -/// move as input, and one which takes a move and a bitboard of pinned -/// pieces. The latter function is faster, and should always be preferred -/// when a pinned piece bitboard has already been computed. +/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal -bool Position::pl_move_is_legal(Move m) const { - - return pl_move_is_legal(m, pinned_pieces(side_to_move())); -} - -bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { +bool Position::pl_move_is_legal(Move m) const { assert(is_ok()); assert(move_is_ok(m)); - assert(pinned == pinned_pieces(side_to_move())); // If we're in check, all pseudo-legal moves are legal, because our // check evasion generator only generates true legal moves. @@ -541,7 +531,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { // A non-king move is legal if and only if it is not pinned or it // is moving along the ray towards or away from the king. - return ( !bit_is_set(pinned, from) + return ( !bit_is_set(pinned_pieces(us), from) || (direction_between_squares(from, ksq) == direction_between_squares(move_to(m), ksq))); } diff --git a/src/position.h b/src/position.h index 3fabf64c..1e7dc992 100644 --- a/src/position.h +++ b/src/position.h @@ -220,7 +220,6 @@ public: // Properties of moves bool pl_move_is_legal(Move m) const; - bool pl_move_is_legal(Move m, Bitboard pinned) const; bool move_is_check(Move m) const; bool move_is_check(Move m, Bitboard dcCandidates) const; bool move_is_capture(Move m) const;