]> git.sesse.net Git - stockfish/commitdiff
Convert also undo_null_move() to avoid passing UndoInfo object
authorMarco Costalba <mcostalba@gmail.com>
Sun, 22 Feb 2009 17:03:23 +0000 (18:03 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 22 Feb 2009 20:18:14 +0000 (21:18 +0100)
No functional change.

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

index 21b00f80536d45cd3fedd9784b7f3bbca1017089..c6c315271f1f27a79ccf15ea616564127e6be4fd 100644 (file)
@@ -1445,10 +1445,12 @@ void Position::do_null_move(UndoInfo& u) {
   assert(!is_check());
 
   // Back up the information necessary to undo the null move to the supplied
-  // UndoInfo object.  In the case of a null move, the only thing we need to
+  // UndoInfo object. In the case of a null move, the only thing we need to
   // remember is the last move made and the en passant square.
   u.lastMove = lastMove;
   u.epSquare = epSquare;
+  u.previous = previous;
+  previous = &u;
 
   // Save the current key to the history[] array, in order to be able to
   // detect repetition draws.
@@ -1473,18 +1475,20 @@ void Position::do_null_move(UndoInfo& u) {
 
 /// Position::undo_null_move() unmakes a "null move".
 
-void Position::undo_null_move(const UndoInfo &u) {
+void Position::undo_null_move() {
 
   assert(is_ok());
   assert(!is_check());
 
-  // Restore information from the supplied UndoInfo object:
-  lastMove = u.lastMove;
-  epSquare = u.epSquare;
+  // Restore information from the our UndoInfo object
+  lastMove = previous->lastMove;
+  epSquare = previous->epSquare;
+  previous = previous->previous;
+
   if (epSquare != SQ_NONE)
       key ^= zobEp[epSquare];
 
-  // Update the necessary information.
+  // Update the necessary information
   sideToMove = opposite_color(sideToMove);
   rule50--;
   gamePly--;
@@ -1942,7 +1946,7 @@ bool Position::has_mate_threat(Color c) {
 
   // Undo null move, if necessary
   if (c != stm)
-      undo_null_move(u1);
+      undo_null_move();
 
   return result;
 }
index c132c8f88a5bb56c576108f2486ca66dad38997d..7300c9d7bd1b85c8b3125f5220d36ef787ce20d7 100644 (file)
@@ -244,7 +244,7 @@ public:
   void do_move(Move m, UndoInfo &u);
   void undo_move(Move m);
   void do_null_move(UndoInfo &u);
-  void undo_null_move(const UndoInfo &u);
+  void undo_null_move();
 
   // Static exchange evaluation
   int see(Square from, Square to) const;
index 3b81fa86dae57f154d2a41df79620c14a0e6bfb5..8c847714150b7d74668f73a1ef2833f29c311b03 100644 (file)
@@ -1201,7 +1201,7 @@ namespace {
             && pos.see(ss[ply + 1].currentMove) + nullValue >= beta)
             nullDrivenIID = true;
 
-        pos.undo_null_move(u);
+        pos.undo_null_move();
 
         if (value_is_mate(nullValue))
         {