\r
#include "board.h"\r
#include "engine.h"\r
+#include "gui.h"\r
#include "move.h"\r
#include "move_do.h"\r
#include "move_legal.h"\r
#include "line.h"\r
#include "uci.h"\r
\r
+\r
// constants\r
\r
static const bool UseDebug = FALSE;\r
\r
do {\r
engine_get(uci->engine,string);\r
+ // Handle the case that the engine is really a WB engine somewhat gracefully.\r
+ if((strstr(string,"Illegal") || strstr(string,"Error"))\r
+ &&strstr(string,"uci")){\r
+ my_fatal("uci_open(): Not an UCI engine.\n");\r
+ }\r
event = uci_parse(uci,string);\r
} while (!engine_eof(Engine) && (event & EVENT_UCI) == 0);\r
}\r
uci->root_move = MoveNone;\r
uci->root_move_pos = 0;\r
uci->root_move_nb = board_mobility(uci->board);\r
+\r
+ uci->multipvSP=0;\r
}\r
\r
// uci_send_isready()\r
parse_open(parse,string);\r
\r
if (parse_get_word(parse,command,StringSize)) {\r
-\r
+ \r
parse_get_string(parse,argument,StringSize);\r
if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" ARGUMENT \"%s\"\n",command,argument);\r
\r
ASSERT(!my_string_empty(argument));\r
\r
n = atoi(argument);\r
- if(Uci->multipv_mode) multipvline=n;\r
+ multipvline=n;\r
\r
ASSERT(n>=1);\r
\r
\r
parse_close(parse);\r
\r
- // update display\r
- //lousy uci,filter out lower depth multipv lines that have been repeated from the engine \r
- if(multipvline>1 && uci->depth<uci->best_depth) event &= ~EVENT_PV;\r
+\r
+ // code by HGM\r
if ((event & EVENT_PV) != 0) {\r
uci->best_score = uci->score; \r
- uci->best_depth = uci->depth;\r
- if(multipvline==1)uci->depth=-1; //HACK ,clears the engine outpout window,see send_pv in adapter.cpp \r
uci->best_sel_depth = uci->sel_depth;\r
line_copy(uci->best_pv,uci->pv);\r
}\r
+ if(uci->depth < uci->best_depth){\r
+ // ignore lines of lower depth\r
+ event &= ~EVENT_PV;\r
+ } else {\r
+ if(uci->depth > uci->best_depth) {\r
+ // clear stack when we start new depth\r
+ uci->multipvSP = 0; \r
+ }\r
+ uci->best_depth = uci->depth;\r
+ if(multipvline >= 1) {\r
+ int i;\r
+ for(i=0; i<uci->multipvSP; i++) {\r
+ if(uci->score == uci->multipvScore[i] && uci->pv[0] == uci->multipvMove[i]) {\r
+ event &= ~EVENT_PV; // ignore duplicates\r
+ }\r
+ }\r
+ if(event & EVENT_PV){\r
+ // line is new, try to add to stack\r
+ if(uci->multipvSP<MultiPVStackSize){\r
+ uci->multipvMove[uci->multipvSP] = uci->pv[0];\r
+ uci->multipvScore[uci->multipvSP] = uci->score;\r
+ uci->multipvSP++;\r
+ }else{\r
+ my_fatal("parse_info(): multipv stack overflow.");\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+\r
return event;\r
}\r
\r