From 70a30c0a0c9a43de477a13a75e8f9d5c05762afc Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 17 Apr 2012 20:05:20 +0200 Subject: [PATCH] Make translation of FEN with holdings also handle S-Chess Like in Shogi FEN, UCI S-Chess engines have the holdings not immediately behind the board, but before the move counters. Since Shogi FENs are missing a few fields in this area (castling, e.p. and 50-move), some recoding was necessary to make this work. --- UCI2WB.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index b2c4583..2ea2512 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -269,7 +269,7 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q; + char line[256], command[256], *p, *q, *r; while(1) { int i, x; @@ -336,10 +336,13 @@ GUI2Engine() } else if(!strcmp(command, "setboard")) { if(strstr(line+9, " b ")) stm = BLACK; - if(sc == 's' && (p = strchr(line+9, '['))) { char c; - *p++ = ' '; q = strchr(p, ']'); c = 'w' + 'b' - q[2]; strcpy(q+2, " 1\n"); while(*--q != ' ') q[2] = *q; *p = c; p[1] = ' '; - } - sprintf(iniPos, "%s%sfen %s", iniPos[0]=='p' ? "position " : "", sc=='s' ? "s" : "", line+9); + if(p = strchr(line+9, '[')) { char c; + *p++ = 0; q = strchr(p, ']'); *q = 0; r = q + 4; + if(sc == 's') q[2] = 'w' + 'b' - q[2], strcpy(r=q+3, " 1\n"); // Shogi: reverse color + else r = strchr(strchr(q+4, ' ') + 1, ' '); // skip to second space (after e.p. square) + *r = 0; sprintf(command, "%s%s %s %s", line+9, q+1, p, r+1); + } else strcpy(command, line+9); + sprintf(iniPos, "%s%sfen %s", iniPos[0]=='p' ? "position " : "", sc=='s' ? "s" : "", command); iniPos[strlen(iniPos)-1] = 0; } else if(!strcmp(command, "variant")) { -- 1.7.0.4