Specify license and include GPL text
[uci2wb.git] / UCI2WB.c
index 7aaad84..9704071 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -1,4 +1,13 @@
-/************************* UCI2WB by H.G.Muller ****************************/\r
+/****************************************************************************/\r
+/*                           UCI2WB by H.G.Muller                           */\r
+/*                                                                          */\r
+/* UCI2WB is an adapter to run engines that communicate in various dialects */\r
+/* of the Universal Chess Interface in a GUI that supports XBoard protocol  */\r
+/* (CECP). It supports UCI (when used for Xiangqi: the 'Cyclone dialect'),  */\r
+/* as well as USI and UCCI when used with the flags -s or -x, respectively. */\r
+/* This version of UCI2WB is released under the GNU General Public License, */\r
+/* of which you should have received a copy together with this file.        */\r
+/****************************************************************************/\r
 \r
 #define VERSION "2.0"\r
 \r
@@ -120,7 +129,7 @@ Play(int nr)
        FromFEN(iniPos + 4); // in XQ iniPos always has just "fen " prefix\r
        for(i=0; i<nr; i++) {\r
            int from=Sqr(move[i], 0), to=Sqr(move[i], 2);\r
-           if(board[to]) last = i;\r
+           if(board[to] || (board[from]|32)  == 'p' && move[i][1] != move[i][3]) last = i;\r
            board[to] = board[from]; board[from] = 0;\r
        }\r
        return last;\r
@@ -383,7 +392,7 @@ GUI2Engine()
       nomove:\r
        fflush(toE); fflush(stdout);\r
        i = 0; while((x = getchar()) != EOF && (line[i] = x) != '\n') i++;\r
-       line[++i] = 0; if(x == EOF) { printf("# EOF\n"); exit(-1); }\r
+       line[++i] = 0; if(x == EOF) { printf("# EOF\n"); fprintf(toE, "quit\n"); exit(-1); }\r
        sscanf(line, "%s", command);\r
        if(!strcmp(command, "new")) {\r
            computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0;\r
@@ -430,7 +439,7 @@ GUI2Engine()
        }\r
        else if(!strcmp(command, "protover")) {\r
            if(!variants) variants = sc=='s' ? "shogi,5x5+5_shogi" : VARIANTS;\r
-           printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 pause=1 done=0\n", variants);\r
+           printf("feature variants=\"%s\" setboard=1 usermove=1 debug=1 ping=1 reuse=0 exclude=1 pause=1 sigint=0 sigterm=0 done=0\n", variants);\r
            printf("feature option=\"UCI2WB debug output -check %d\"\n", debug);\r
            fprintf(toE, sc == 'x' ? "ucci\n" : "u%ci\n", sc); fflush(toE); // prompt UCI engine for options\r
            Sync(PAUSE); // wait for uciok\r