Take account of multi-session TC while pondering
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 7 Mar 2014 09:47:38 +0000 (10:47 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 7 Mar 2014 10:39:56 +0000 (11:39 +0100)
We now call RenewTimeControl rather than SetTimeControl to calculate
the new TC parameters when a ponder search produces a move after a
ponder hit, to mimic what would happen if the computer thinks in
the main loop. When accepting the ponder move during search we should
be more careful, because calling the SetTimeControl (indirectly) there
would interfere with the 'time' and 'otim' commands received just
before the move, which already include the time for the next session.
So there we only set the number of moves when a new session starts.
This would not take account of multi-session TCs, but in XBoard mode
there shouldn't be any.

gnushogi/commondsp.c

index 802bb1b..6272918 100644 (file)
@@ -1600,8 +1600,6 @@ ReadFEN(char *fen)
 }
 
 
-/* FIXME!  This is truly the function from hell! */
-
 /*
  * Process the user's command. If easy mode is OFF (the computer is thinking
  * on opponents time) and the program is out of book, then make the 'hint'
@@ -1682,8 +1680,7 @@ PonderOnHintMove(void)
                 ElapsedTime(COMPUTE_AND_INIT_MODE);
                 GameList[GameCnt-1].time = (short) (et + 50)/100; /* FIXME: this is wrong */
 
-                if(TCflag && TimeControl.moves[computer] == 0)
-                    SetTimeControl(); /* add time for next session */
+                RenewTimeControl(computer); /* add time for next session */
             }
             Sdepth = 0;
         }
@@ -2241,8 +2238,8 @@ InputCommand(int root)
             {   /* account opponent time and moves */
                 TimeControl.clock[opponent] -= et;
                 timeopp[oppptr] = et;
-                --TimeControl.moves[opponent];
-                if(TimeControl.moves[computer] == 0) SetTimeControl();
+                if (--TimeControl.moves[opponent] == 0)
+                    TimeControl.moves[opponent] = TCmoves; /* assumes uni-TC! */
             }
             SetResponseTime(computer);
             strcpy(ponderString, "hit");