From 21575c894ab0f3a7170a403dfc8030a0b75d8f92 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Wed, 21 Sep 2016 14:42:20 +0200 Subject: [PATCH] Send game result to USI engines The USI 'gameover' command is now used as translation of the CECP 'result' command, to relay the result to the engine. To decide how the absolute game result (white/black) is translated to a relative one (win/lose), the side last moved for is used as indication, and remembered whenever the engine is set thinking on a move (as it could already be switched to force mode at the time the 'result' command is received). --- UCI2WB.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index 459c748..62e17e4 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -379,7 +379,7 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q, *r; + char line[256], command[256], *p, *q, *r, mySide; while(1) { int i, x; @@ -388,7 +388,7 @@ GUI2Engine() DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) - startTime = GetTickCount(); + startTime = GetTickCount(); mySide = stm; // remember side we last played for if(computer == ANALYZE) { fprintf(toE, "\ngo infinite"); DPRINT("\n# go infinite"); if(sm & 1) { // some moves are disabled @@ -517,6 +517,7 @@ GUI2Engine() else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth); else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0, sTime /= unit; else if(!strcmp(command, "offer")) drawOffer = 1; + else if(!strcmp(command, "result")) { if(sc == 's') fprintf(toE, "gameover %s\n", line[8] == '/' ? "draw" : (line[7] == '0') == mySide ? "win" : "lose"); } else if(!strcmp(command, "quit")) fprintf(toE, "quit\n"), fflush(toE), exit(0); } } -- 1.7.0.4