NPS plays and pondering
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 23 Oct 2009 04:28:38 +0000 (21:28 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 23 Oct 2009 04:28:38 +0000 (21:28 -0700)
Clock updating did not work correctly in node-based time controls when the
engine was pondering. (It was not really meant for use with pondering. Oh well...)
This patch checks if the engine reporting the node count is indeed thinking
(as opposed to pondering).

backend.c

index 54f337d..4582baa 100755 (executable)
--- a/backend.c
+++ b/backend.c
@@ -6945,9 +6945,12 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats.
 
                        if(cps->nps == 0) ticklen = 10*time;                    // use engine reported time
                        else ticklen = (1000. * u64ToDouble(nodes)) / cps->nps; // convert node count to time
-                       if(WhiteOnMove(forwardMostMove)) 
+                       if(WhiteOnMove(forwardMostMove) && (gameMode == MachinePlaysWhite ||
+                                               gameMode == TwoMachinesPlay && cps->twoMachinesColor[0] == 'w')) 
                             whiteTimeRemaining = timeRemaining[0][forwardMostMove] - ticklen;
-                       else blackTimeRemaining = timeRemaining[1][forwardMostMove] - ticklen;
+                       if(!WhiteOnMove(forwardMostMove) && (gameMode == MachinePlaysBlack ||
+                                               gameMode == TwoMachinesPlay && cps->twoMachinesColor[0] == 'b')) 
+                            blackTimeRemaining = timeRemaining[1][forwardMostMove] - ticklen;
                }
 
                /* Buffer overflow protection */