From 7295e7b8f71c001f64930229b3d99cf8b2245a9e Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 1 Apr 2014 18:20:29 +0200 Subject: [PATCH] Allow pseudo-engines to adjust the clocks Implement new options -first/secondPseudo, which declare the corresponding engine to be a pseudo-engine, which will then be granted super-powers through some new engine->GUI commands. For instance, to adjust the time remaining on the GUI clocks through wtime and btime commands (using msec). --- args.h | 2 ++ backend.c | 6 ++++++ backend.h | 1 + common.h | 1 + 4 files changed, 10 insertions(+), 0 deletions(-) diff --git a/args.h b/args.h index e8ef298..19324d7 100644 --- a/args.h +++ b/args.h @@ -681,6 +681,8 @@ ArgDescriptor argDescriptors[] = { { "scoreWhite", ArgBoolean, (void *) &appData.scoreWhite, TRUE, FALSE }, { "evalZoom", ArgInt, (void *) &appData.zoom, TRUE, (ArgIniType) 1 }, { "evalThreshold", ArgInt, (void *) &appData.evalThreshold, TRUE, (ArgIniType) 25 }, + { "firstPseudo", ArgTrue, (void *) &appData.pseudo[0], FALSE, FALSE }, + { "secondPseudo", ArgTrue, (void *) &appData.pseudo[1], FALSE, FALSE }, { "fSAN", ArgTrue, (void *) &appData.pvSAN[0], FALSE, FALSE }, { "sSAN", ArgTrue, (void *) &appData.pvSAN[1], FALSE, FALSE }, { "pairingEngine", ArgFilename, (void *) &appData.pairingEngine, TRUE, "" }, diff --git a/backend.c b/backend.c index 39467ae..5771996 100644 --- a/backend.c +++ b/backend.c @@ -847,6 +847,7 @@ InitEngine (ChessProgramState *cps, int n) cps->analyzing = FALSE; cps->initDone = FALSE; cps->reload = FALSE; + cps->pseudo = appData.pseudo[n]; /* New features added by Tord: */ cps->useFEN960 = FALSE; @@ -9136,6 +9137,10 @@ printf("score=%d count=%d\n",score,count); Don't use it. */ cps->sendTime = 0; } + if (cps->pseudo) { // [HGM] pseudo-engine, granted unusual powers + if (sscanf(message, "wtime %ld\n", &whiteTimeRemaining) == 1 || // adjust clock times + sscanf(message, "btime %ld\n", &blackTimeRemaining) == 1 ) return; + } /* * If chess program startup fails, exit with an error message. @@ -10841,6 +10846,7 @@ SwapEngines (int n) SWAP(accumulateTC, h) SWAP(drawDepth, h) SWAP(host, p) + SWAP(pseudo, h) } int diff --git a/backend.h b/backend.h index b304cb4..2acd187 100644 --- a/backend.h +++ b/backend.h @@ -343,6 +343,7 @@ typedef struct XB_CPS { int analyzing; int protocolVersion; int initDone; + int pseudo; /* Added by Tord: */ int useFEN960; /* 0=use "KQkq" style FENs, 1=use "HAha" style FENs */ diff --git a/common.h b/common.h index bf26600..3d92dc0 100644 --- a/common.h +++ b/common.h @@ -661,6 +661,7 @@ typedef struct { int adjudicateDrawMoves; Boolean autoDisplayComment; Boolean autoDisplayTags; + Boolean pseudo[ENGINES]; /* [HGM] pseudo-engines */ Boolean isUCI[ENGINES]; Boolean hasOwnBookUCI[ENGINES]; char * adapterCommand; -- 1.7.0.4