X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=4d132e033244e602fd0f1edfeedfe3244a7759fe;hp=ec86f35ce73ebecb16c6394604d150c28e8e53e1;hb=595c7d75a2d8c6bc6beade1aa0c50fcf79083661;hpb=5603e25a7fb7fca1d5764078046b875b31583fde diff --git a/src/position.cpp b/src/position.cpp index ec86f35c..4d132e03 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1413,11 +1413,13 @@ void Position::do_null_move(StateInfo& backupSt) { assert(!is_check()); // Back up the information necessary to undo the null move to the supplied - // StateInfo object. In the case of a null move, the only thing we need to - // remember is the en passant square. + // StateInfo object. // Note that differently from normal case here backupSt is actually used as // a backup storage not as a new state to be used. backupSt.epSquare = st->epSquare; + backupSt.key = st->key; + backupSt.mgValue = st->mgValue; + backupSt.egValue = st->egValue; backupSt.previous = st->previous; st->previous = &backupSt; @@ -1451,19 +1453,15 @@ void Position::undo_null_move() { // Restore information from the our backup StateInfo object st->epSquare = st->previous->epSquare; + st->key = st->previous->key; + st->mgValue = st->previous->mgValue; + st->egValue = st->previous->egValue; st->previous = st->previous->previous; - if (st->epSquare != SQ_NONE) - st->key ^= zobEp[st->epSquare]; - // Update the necessary information sideToMove = opposite_color(sideToMove); st->rule50--; gamePly--; - st->key ^= zobSideToMove; - - st->mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame; - st->egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame; assert(is_ok()); }