]> git.sesse.net Git - stockfish/commitdiff
Rename move_is_legal() in move_is_pl()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 23 May 2011 10:04:59 +0000 (12:04 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 23 May 2011 19:20:42 +0000 (20:20 +0100)
We disjoint pseudo legal detection from full legal detection.

It will be used by future patches.

No functional change.

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

index f38d42261ccfbdf827cdc5d9ad1c813f812a4aff..297b51ffdeacb7e6d633be647d9e3da3a89ffc49 100644 (file)
@@ -451,7 +451,7 @@ namespace {
     // Single and double pawn pushes
     if (Type != MV_CAPTURE)
     {
-        b1 = pawnPushes & emptySquares;
+        b1 = (Type != MV_EVASION ? pawnPushes : pawnPushes & emptySquares);
         b2 = move_pawns<TDELTA_N>(pawnPushes & TRank3BB) & emptySquares;
 
         if (Type == MV_CHECK)
index 69d60bade0f5fc93abeb087f1c6463fe1a241abc..6a4b26eef6e92bae6d1efd5cb774ab712be108cd 100644 (file)
@@ -275,7 +275,8 @@ Move MovePicker::get_next_move() {
       case PH_TT_MOVES:
           move = (curMove++)->move;
           if (   move != MOVE_NONE
-              && pos.move_is_legal(move, pinned))
+              && pos.move_is_pl(move)
+              && pos.pl_move_is_legal(move, pinned))
               return move;
           break;
 
@@ -300,7 +301,8 @@ Move MovePicker::get_next_move() {
       case PH_KILLERS:
           move = (curMove++)->move;
           if (   move != MOVE_NONE
-              && pos.move_is_legal(move, pinned)
+              && pos.move_is_pl(move)
+              && pos.pl_move_is_legal(move, pinned)
               && move != ttMoves[0].move
               && move != ttMoves[1].move
               && !pos.move_is_capture(move))
index 3cc3bfebcdde3a8496ac3ba81b1a73df89f37e76..4c925f5bba16fc51b8f2417668d0159e47ee450e 100644 (file)
@@ -628,14 +628,14 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
 /// 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_legal(const Move m) const {
+bool Position::move_is_pl_full(const Move m) const {
 
   MoveStack mlist[MAX_MOVES];
   MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);
 
    for (cur = mlist; cur != last; cur++)
       if (cur->move == m)
-          return pl_move_is_legal(m, pinned_pieces(sideToMove));
+          return true;
 
   return false;
 }
@@ -644,10 +644,9 @@ bool Position::move_is_legal(const Move m) const {
 /// Fast version of Position::move_is_legal() that takes a position a move and
 /// a bitboard of pinned pieces as input, and tests whether the move is legal.
 
-bool Position::move_is_legal(const Move m, Bitboard pinned) const {
+bool Position::move_is_pl(const Move m) const {
 
   assert(is_ok());
-  assert(pinned == pinned_pieces(sideToMove));
 
   Color us = sideToMove;
   Color them = opposite_color(sideToMove);
@@ -657,7 +656,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
 
   // Use a slower but simpler function for uncommon cases
   if (move_is_special(m))
-      return move_is_legal(m);
+      return move_is_pl_full(m);
 
   // Is not a promotion, so promotion piece must be empty
   if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
@@ -763,8 +762,7 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
       }
   }
 
-  // The move is pseudo-legal, check if it is also legal
-  return pl_move_is_legal(m, pinned);
+  return true;
 }
 
 
index e560a097330d1ec0f65c0a8364d59551334aaac3..496b7b9d00fe4e763da4f8fcff4bc69448da87ec 100644 (file)
@@ -186,8 +186,8 @@ public:
 
   // Properties of moves
   bool pl_move_is_legal(Move m, Bitboard pinned) const;
-  bool move_is_legal(const Move m) const;
-  bool move_is_legal(const Move m, Bitboard pinned) const;
+  bool move_is_pl_full(const Move m) const;
+  bool move_is_pl(const Move m) const;
   bool move_gives_check(Move m) const;
   bool move_gives_check(Move m, const CheckInfo& ci) const;
   bool move_is_capture(Move m) const;
index 2fdd2840ea2b38915c453baf46783cc097909b35..516ff100868655264da9f18a7f2b6282eb61a474 100644 (file)
@@ -1979,13 +1979,16 @@ split_point_start: // At split points actual search starts from here
     TTEntry* tte;
     int ply = 1;
 
-    assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0]));
+    assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));
 
     pos.do_move(pv[0], *st++);
 
+    Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
+
     while (   (tte = TT.probe(pos.get_key())) != NULL
            && tte->move() != MOVE_NONE
-           && pos.move_is_legal(tte->move())
+           && pos.move_is_pl(tte->move())
+           && pos.pl_move_is_legal(tte->move(), pinned)
            && ply < PLY_MAX
            && (!pos.is_draw() || ply < 2))
     {
@@ -2009,7 +2012,7 @@ split_point_start: // At split points actual search starts from here
     Value v, m = VALUE_NONE;
     int ply = 0;
 
-    assert(pv[0] != MOVE_NONE && pos.move_is_legal(pv[0]));
+    assert(pv[0] != MOVE_NONE && pos.move_is_pl(pv[0]));
 
     do {
         k = pos.get_key();