X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=26010a201e2b1b68af1af5d6455cae5060a1c6c1;hp=53b2f19bd738af77078a72ab6ffc82d1b4dbf264;hb=1b936bccc1ce09ac1ea15a4186b3bbc51eacaaf8;hpb=b7c746a0f37859a73d49a9cdb03cf3b32ce1391e diff --git a/UCI2WB.c b/UCI2WB.c index 53b2f19..26010a2 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -1,6 +1,6 @@ /************************* UCI2WB by H.G.Muller ****************************/ -#define VERSION "1.6" +#define VERSION "1.7" #include #include @@ -30,7 +30,7 @@ #define NONE 2 #define ANALYZE 3 -char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix; +char move[2000][10], checkOptions[8192], iniPos[256], hashOpt[20], pause, pondering, ponder, post, hasHash, c, sc='c', *suffix, *variants; int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug; int statDepth, statScore, statNodes, statTime, currNr, size; char currMove[20]; // for analyze mode @@ -171,6 +171,8 @@ Engine2GUI() line[13] = '=', line[14] = 0; } } + if(line[9] == 'e' && (line[14] == 'a' || line[14] == 'h')) // seirawan castling + gating at Rook + line[9] = line[14], line[11] = 'e'; // convert to RxK notation printf("move %s\n", line+9); // send move to GUI if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == WHITE ? "1-0" : "0-1"); computer = NONE; } stm = WHITE+BLACK - stm; @@ -178,6 +180,7 @@ Engine2GUI() else if(!strcmp(command, "info")) { int d=0, s=0, t=0, n=0; char *pv; + if(sscanf(line+5, "string times @ %c", &dummy) == 1) { printf("# %s", line+12); continue; } if(!post) continue; if(sscanf(line+5, "string %c", &dummy) == 1) printf("%d 0 0 0 %s", lastDepth, line+12); else { if(p = strstr(line+4, " depth ")) sscanf(p+7, "%d", &d), statDepth = d; @@ -281,6 +284,11 @@ GUI2Engine() else if(line[13] != '\n') line[13] = '+'; // cater to WB 4.4 bug :-( } sscanf(line, "usermove %s", command); // strips off linefeed + if(command[4] && (command[1] == '1' || command[1] == '8')) { // seirawan gating + command[5] = command[0], command[6] = command[1], command[7] = '\0'; + if(command[2] == 'e' && (command[0] == 'a' || command[0] == 'h')) + command[2] = (command[0]+command[2]+1)>>1, command[0] = 'e'; // gating at Rook + } stm = WHITE+BLACK - stm; // when pondering we either continue the ponder search as normal search, or abort it if(pondering || computer == ANALYZE) { @@ -291,7 +299,8 @@ GUI2Engine() } StopPonder(1); } - sscanf(line, "usermove %s", move[moveNr++]); // possibly overwrites ponder move +// sscanf(line, "usermove %s", move[moveNr++]); // possibly overwrites ponder move + strcpy(move[moveNr++], command); } else if(!strcmp(command, "level")) { int sec = 0; @@ -309,7 +318,8 @@ GUI2Engine() } else { fprintf(toE, "setoption name %s\n", line+7); DPRINT("# setoption name %s\n", line+7); } } else if(!strcmp(command, "protover")) { - printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS); + if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS; + printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 done=0\n", variants); printf("feature option=\"UCI2WB debug output -check %d\"\n", debug); fprintf(toE, "u%ci\n", sc); // this prompts UCI engine for options } @@ -349,7 +359,7 @@ GUI2Engine() else if(!strcmp(command, "memory")) sscanf(line, "memory %d", &memory); else if(!strcmp(command, "cores")) sscanf(line, "cores %d", &cores); else if(!strcmp(command, "sd")) sscanf(line, "sd %d", &depth); - else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime *= 1000, inc = 0; + else if(!strcmp(command, "st")) sscanf(line, "st %d", &sTime), sTime = 1000*sTime - 30, inc = 0; else if(!strcmp(command, "quit")) fprintf(toE, "quit\n"), fflush(toE), exit(0); } } @@ -445,6 +455,7 @@ main(int argc, char **argv) if(argc == 2 && !strcmp(argv[1], "-v")) { printf("UCI2WB " VERSION " by H.G.Muller\n"); exit(0); } if(argc > 1 && !strcmp(argv[1], "debug")) { debug = 1; argc--; argv++; } + if(argc > 1 && !strcmp(argv[1], "-var")) { variants = argv[2]; argc-=2; argv+=2; } if(argc > 1 && argv[1][0] == '-') { sc = argv[1][1]; argc--; argv++; } if(argc < 2) { printf("usage is: U%cI2WB [debug] [-s] []\n", sc-32); exit(-1); } if(argc > 2) dir = argv[2];