From 9106cb55be2eee65075e4cd9954d371c82ecd8e0 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 27 Oct 2014 23:35:31 +0100 Subject: [PATCH] Compactify timing code by figuring out who is black first A new variable 'black' is set when the engine plays black, to know if the XBoard 'time' setting should be transmitted as 'wtim' or 'btim'. --- UCI2WB.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index 95fe411..3354603 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -35,7 +35,6 @@ int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, o int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500]; char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20]; char board[100]; // XQ board for UCCI -char *nameWord = "name ", *valueWord = "value ", *wTime = "w", *bTime = "b", *wInc = "winc", *bInc = "binc"; // keywords that differ in UCCI int unit = 1; FILE *toE, *fromE, *fromF; @@ -129,10 +128,11 @@ Play(int nr) void StartSearch(char *ponder) { // send the 'go' command to engine. Suffix by ponder. - int x = (ponder[0] != 0); - int nr = moveNr + x; // we ponder for one move ahead! - fprintf(toE, "\ngo%s btime %d wtime %d", ponder, stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); - DPRINT( "\n# go%s btime %d wtime %d", ponder, stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime); + int x = (ponder[0] != 0); // during ponder stm is the opponent + int black = (stm == BLACK ^ x ^ sc == 's'); // set if our color is what the engine calls black + int nr = moveNr + x; // we ponder for one move ahead! + fprintf(toE, "\ngo%s btime %d wtime %d", ponder, black ? myTime : hisTime, !black ? myTime : hisTime); + DPRINT( "\n# go%s btime %d wtime %d", ponder, black ? myTime : hisTime, !black ? myTime : hisTime); if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); } if(inc && !suffix) { fprintf(toE, " winc %d binc %d", inc, inc); DPRINT(" winc %d binc %d", inc, inc); } -- 1.7.0.4