From 05c7d739a244a923c0f3e90bcb10f3db9f5e670c Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 10 Nov 2016 10:12:11 +0100 Subject: [PATCH] Fix commands during analysis (MultiPV option!) UCI2WB could not handle spurious commands while analyzing: these would start a new search without first terminating the old one. Only the commands allowed in analysis mode (exit, usermove, and in/exclude) were handled correctly. Unfortunately XBoard sometimes sends spurious 'accepted' commands during analysis, in violation of the CECP specs. All such non-compliant commands are now ignored. And the 'option' command will also abort an ongoing analysis search, to allow altering the MultiPV setting during analysis. (Something XBoard also does.) --- README.txt | 1 + UCI2WB.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.txt b/README.txt index 41e2d80..09d94ae 100644 --- a/README.txt +++ b/README.txt @@ -54,6 +54,7 @@ Change log: Implement handling of 'UCI_Variant' option for variant announcement and selection Pass 'info string variant' line as 'setup' command to allow engine-defined variants Set 'UCI_Opponent' option in accordance with CECP 'name' and 'computer' commands +Fix option setting during analysis (MultiPV!) 22/11/2016 2.2 Use USI gameover command to relay game result diff --git a/UCI2WB.c b/UCI2WB.c index dddb073..dffac3b 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -395,12 +395,12 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q, *r, mySide; + char line[256], command[256], *p, *q, *r, mySide, searching = 0; while(1) { int i, x; - if((computer == stm || computer == ANALYZE) && !suspended) { + if((computer == stm || computer == ANALYZE && !searching) && !suspended) { DPRINT("# start search\n"); LoadPos(moveNr); fflush(stdout); // load position // and set engine thinking (note USI swaps colors!) @@ -411,8 +411,7 @@ GUI2Engine() fprintf(toE, " searchmoves"); DPRINT(" searchmoves"); for(i=1; i 0) fprintf(toE, "setoption name UCI_Chess960 value true\n"); } } else if(!strcmp(command, "undo") && (i=1) || !strcmp(command, "remove") && (i=2)) { - if(pondering || computer == ANALYZE) StopPonder(1); + if(pondering || computer == ANALYZE) StopPonder(1), searching = 0; moveNr = moveNr > i ? moveNr - i : 0; collect = (computer == ANALYZE); sm = 0; } else if(!strcmp(command, ".")) { @@ -510,7 +510,7 @@ GUI2Engine() inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i