From 2f21ec39adcfc3a2ce4d4fd08eb1fa688c4e67a7 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 22 Feb 2009 18:03:23 +0100 Subject: [PATCH] Convert also undo_null_move() to avoid passing UndoInfo object No functional change. Signed-off-by: Marco Costalba --- src/position.cpp | 18 +++++++++++------- src/position.h | 2 +- src/search.cpp | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 21b00f80..c6c31527 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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; } diff --git a/src/position.h b/src/position.h index c132c8f8..7300c9d7 100644 --- a/src/position.h +++ b/src/position.h @@ -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; diff --git a/src/search.cpp b/src/search.cpp index 3b81fa86..8c847714 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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)) { -- 2.39.2