X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=77b671b7b633cefba7715f06e5f0076b82ec0635;hp=bd8a4f8071a4e1a1019d640d8ea99126fb8e7adb;hb=d4c964cc8830407dbc9efa12a1d50e4ce48b711a;hpb=a0e8b912242887c25e8fd5dedcfcb72b31b29434 diff --git a/UCI2WB.c b/UCI2WB.c index bd8a4f8..77b671b 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -1,6 +1,6 @@ /************************* UCI2WB by H.G.Muller ****************************/ -#define VERSION "1.10" +#define VERSION "2.0" #include #include @@ -35,8 +35,8 @@ 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; +char *nameWord = "name ", *valueWord = "value ", *wTime = "w", *bTime = "b", *wInc = "winc", *bInc = "binc", newGame; // keywords that differ in UCCI +int unit = 1, drawOffer; FILE *toE, *fromE, *fromF; int pid; @@ -132,6 +132,8 @@ StartSearch(char *ponder) 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! + if(sc == 'x') black = 1; else drawOffer = 0;// in UCCI 'black' refers to us and 'white' to opponent + if(!x && drawOffer) ponder = " draw", drawOffer = 0; //pass draw offer only when not pondering fprintf(toE, "\ngo%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime); DPRINT( "\n# go%s %stime %d %stime %d", ponder, bTime, black ? myTime : hisTime, wTime, !black ? myTime : hisTime); if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else @@ -146,7 +148,7 @@ void StopPonder(int pondering) { if(!pondering) return; - pause = 1; + pause = 2; fprintf(toE, "stop\n"); fflush(toE); DPRINT("# stop\n"); // note: 'pondering' remains set until engine acknowledges 'stop' with 'bestmove' Sync(PAUSE); // wait for engine to acknowledge 'stop' with 'bestmove'. } @@ -154,10 +156,16 @@ StopPonder(int pondering) void LoadPos(int moveNr) { - int j; - fprintf(toE, "%s moves", iniPos); - DPRINT( "# %s moves", iniPos); - for(j=0; j 2) dir = argv[2]; if(argc > 3) suffix = argv[3]; + if(sc == 'x') nameWord = valueWord = bTime = "", wTime = "opp", bInc = "increment", wInc = "oppincrement", unit = 1000; // switch to UCCI keywords + // spawn engine proc if(StartEngine(argv[1], dir) != NO_ERROR) { perror(argv[1]), exit(-1); } @@ -583,7 +604,7 @@ main(int argc, char **argv) #ifdef WIN32 CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) Engine2GUI, (LPVOID) NULL, 0, &thread_id); #else - { pthread_t t; signal(SIGINT, SIG_IGN); pthread_create(&t, NULL, Engine2GUI, NULL); } + { pthread_t t; signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); pthread_create(&t, NULL, Engine2GUI, NULL); } #endif // handle GUI->engine traffic in original thread