From aee345a6b5d8582e826af026fad391d477db7272 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 6 Nov 2016 14:29:08 +0100 Subject: [PATCH] Implement CECP 'setup' command On reception of an "info string variant NAME startpos FEN" from the engine UCI2WB will now send "setup (-) 8x8+0_fairy FEN" to the GUI, to make engine-defined variants also work with UCI engines. Correct operation required sending of an 'isready' command to the engine after setting the UCI_Variant option (which evokes the 'info string' response), and stalling processing of GUI commands until the 'readyok' response, to prevent early processing of a following 'ping' before the engine got time to submit the reply. This way the 'info string' response can be optional. When variant ="chess" the 'info string' is ignored, as such a setting of UCI_Variant only occurs in response to 'new', and never to 'variant'. --- UCI2WB.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index 9b197bb..2370615 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -276,8 +276,12 @@ Engine2GUI() } else if(!strcmp(command, "info")) { int d=0, s=0, t=(GetTickCount() - startTime)/10, n=1; - char *pv; + char *pv, varName[80]; if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; } + if(sscanf(line+5, "string variant %s", varName) == 1) { + if(strcmp(varName,"chess") && (p = strstr(line+18, " startpos "))) printf("setup (-) 8x8+0_fairy %s", p+10); + continue; + } if(collect && (pv = strstr(line+5, "currmove "))) { if(p = strstr(line+5, "currmovenumber ")) { n = atoi(p+15); @@ -481,7 +485,10 @@ GUI2Engine() iniPos[strlen(iniPos)-1] = sm = 0; collect = (computer == ANALYZE); } else if(!strcmp(command, "variant")) { - if(varOpt) fprintf(toE, "setoption name UCI_Variant value %sucinewgame\n", strcmp(line+8, "3check\n") ? line+8 : "threecheck\n"); + if(varOpt) { + fprintf(toE, "setoption name UCI_Variant value %sucinewgame\nisready\n", strcmp(line+8, "3check\n") ? line+8 : "threecheck\n"); + fflush(toE); Sync(PAUSE); + } if(!strcmp(line+8, "shogi\n")) size = 9, strcpy(iniPos, "position startpos"); if(!strcmp(line+8, "5x5+5_shogi\n")) size = 5, strcpy(iniPos, "position startpos"); if(!strcmp(line+8, "xiangqi\n")) strcpy(iniPos, "fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR r"); -- 1.7.0.4