Add time increment after move in XBoard mode
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 7 Mar 2014 11:50:07 +0000 (12:50 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 7 Mar 2014 11:50:07 +0000 (12:50 +0100)
Adding the increment with Fischer clocks was done in SetResponseTime,
so it was included in the time for the current move. The time would
normally already have been added through the 'time' command, however,
so the engine would count itself rich by this, and could be flagged.
In XBoard mode the time increment is now added after the move (just in
case the GUI would not send 'time' commands, which would overrule it
anyway before we have to move next).

gnushogi/search.c
gnushogi/tcontrl.c

index ee7b402..f950a6d 100644 (file)
@@ -451,8 +451,11 @@ SelectMove(short side, SelectMove_mode iop)
 
     /* If Time Control get the elapsed time */
     if (TCflag)
+    {
         ElapsedTime(COMPUTE_AND_INIT_MODE);
-
+        if(xboard) /* In XBoard increment is added after move */
+            TimeControl.clock[side] += TCadd;
+    }
     /* update time control info */
     dsp->OutputMove();
 
index 691f5ae..4e1da41 100644 (file)
@@ -164,7 +164,8 @@ void SetResponseTime(short side)
                 short rtf = in_opening_stage ? 8 : 2;
                 short tcq = in_opening_stage ? 2 : 4;
 
-                TimeControl.clock[side] += TCadd;
+                if(!xboard) /* no pre-add of increment in XBoard mode */
+                    TimeControl.clock[side] += TCadd;
                 ResponseTime = (TimeControl.clock[side])
                     / (((TimeControl.moves[side]) * rtf) + 1);
                 TCleft = (long)ResponseTime / tcq;
@@ -252,7 +253,9 @@ void SetResponseTime(short side)
         else
         {
             /* calculate avg time per move remaining */
-            TimeControl.clock[side] += TCadd;
+
+            if(!xboard) /* no pre-add of increment in XBoard mode */
+                TimeControl.clock[side] += TCadd;
 
             ResponseTime = (TimeControl.clock[side])
                 / (((TimeControl.moves[side]) * 2) + 1);