]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Rewrite previous patch using only one counter
[stockfish] / src / position.cpp
index e0e9aa3a9b37b316dc1b55f02b00755a3305c42b..e30629186fdb65ec9321c1fbb72c064cba268814 100644 (file)
@@ -1238,6 +1238,7 @@ void Position::do_null_move(StateInfo& backupSt) {
   // Note that differently from normal case here backupSt is actually used as
   // a backup storage not as a new state to be used.
   backupSt.key      = st->key;
+  backupSt.rule50   = st->rule50;
   backupSt.epSquare = st->epSquare;
   backupSt.mgValue  = st->mgValue;
   backupSt.egValue  = st->egValue;
@@ -1257,7 +1258,7 @@ void Position::do_null_move(StateInfo& backupSt) {
 
   sideToMove = opposite_color(sideToMove);
   st->epSquare = SQ_NONE;
-  st->rule50++;
+  st->rule50 = 0;
   gamePly++;
 
   st->mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
@@ -1275,6 +1276,7 @@ void Position::undo_null_move() {
   // Restore information from the our backup StateInfo object
   StateInfo* backupSt = st->previous;
   st->key      = backupSt->key;
+  st->rule50   = backupSt->rule50;
   st->epSquare = backupSt->epSquare;
   st->mgValue  = backupSt->mgValue;
   st->egValue  = backupSt->egValue;
@@ -1282,7 +1284,6 @@ void Position::undo_null_move() {
 
   // Update the necessary information
   sideToMove = opposite_color(sideToMove);
-  st->rule50--;
   gamePly--;
 }