From ed04267ec5d67a18b331eb6558729512b790b33d Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 15 Apr 2011 15:41:38 +0200 Subject: [PATCH] Fix running of clock during hash allocation engine In TwoMachinesEvent we now wait for the second engine to acknowledge the 'ping' after 'new', to make sure it is done allocating hash in reaction to the preceding 'memory' command, before the clock for the game is started. --- backend.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 9f9f63e..677e21c 100644 --- a/backend.c +++ b/backend.c @@ -12084,6 +12084,7 @@ TwoMachinesEvent P((void)) char buf[MSG_SIZ]; ChessProgramState *onmove; char *bookHit = NULL; + static int stalling = 0; if (appData.noChessProgram) return; @@ -12120,13 +12121,23 @@ TwoMachinesEvent P((void)) ResurrectChessProgram(); /* in case first program isn't running */ if(WaitForSecond(TwoMachinesEventIfReady)) return; - DisplayMessage("", ""); - InitChessProgram(&second, FALSE); - SendToProgram("force\n", &second); if(first.lastPing != first.lastPong) { // [HGM] wait till we are sure first engine has set up position + DisplayMessage("", _("Waiting for first chess program")); + ScheduleDelayedEvent(TwoMachinesEvent, 10); + return; + } + if(!stalling) { + InitChessProgram(&second, FALSE); + SendToProgram("force\n", &second); + } + if(second.lastPing != second.lastPong) { // [HGM] second engine might have to reallocate hash + if(!stalling) DisplayMessage("", _("Waiting for second chess program")); + stalling = 1; ScheduleDelayedEvent(TwoMachinesEvent, 10); return; } + stalling = 0; + DisplayMessage("", ""); if (startedFromSetupPosition) { SendBoard(&second, backwardMostMove); if (appData.debugMode) { -- 1.7.0.4