]> git.sesse.net Git - stockfish/commitdiff
Do not pass pinned argument in Position::pl_move_is_legal()
authorMarco Costalba <mcostalba@gmail.com>
Thu, 19 Feb 2009 15:48:57 +0000 (16:48 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 19 Feb 2009 15:48:57 +0000 (16:48 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movegen.cpp
src/movepick.cpp
src/position.cpp
src/position.h

index 94bc173e10c94f142043a2ff5c94726f8b3371a0..390305726026b86e3c2a9df3852ec8fd7840cf0b 100644 (file)
@@ -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));
 }
 
index c90f8df1e6d398e2cf7f7ab3a4ae63be7c4f3dc1..4c75b0fe2c00dfb0e464f113e9ad911cb53b57a6 100644 (file)
@@ -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;
index a999b4c6f0e5ee5a67981184e8bd2e89cf52cb90..3bb8fef931c00924a9aa52cf3823fdecda4a73f6 100644 (file)
@@ -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)));
 }
 
index 3fabf64c8156ddac239390d58fcb79bb10f81eb8..1e7dc9926ba24eb80e67c182bd5678ad710de89a 100644 (file)
@@ -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;