return buf;\r
}\r
\r
+void\r
+Move4GUI(char *m)\r
+{\r
+ if(sc == 's') {\r
+ // convert USI move to WB format\r
+ m[2] = 'a'+'0'+size - m[2];\r
+ m[3] = 'a'+'0'+size - m[3];\r
+ if(m[1] == '*') { // drop\r
+ m[1] = '@';\r
+ } else {\r
+ m[0] = 'a'+'0'+size - m[0];\r
+ m[1] = 'a'+'0'+size - m[1];\r
+ if((stm == WHITE ? (m[1]>'0'+size-size/3 || m[3]>'0'+size-size/3)\r
+ : (m[1] <= '0'+size/3 || m[3] <= '0'+size/3)) && m[4] != '+')\r
+ m[4] = '=', m[5] = 0;\r
+ }\r
+ }\r
+ if(m[0] == 'e' && (m[5] == 'a' || m[5] == 'h')) // seirawan castling + gating at Rook\r
+ m[0] = m[5], m[2] = 'e'; // convert to RxK notation\r
+}\r
+\r
void *\r
Engine2GUI()\r
{\r
}\r
p[-1] = '\n'; *p = 0; // strip off ponder move\r
}\r
- if(sc == 's') {\r
- // convert USI move to WB format\r
- line[11] = 'a'+'0'+size - line[11];\r
- line[12] = 'a'+'0'+size - line[12];\r
- if(line[10] == '*') { // drop\r
- line[10] = '@';\r
- } else {\r
- line[9] = 'a'+'0'+size - line[9];\r
- line[10] = 'a'+'0'+size - line[10];\r
- if((stm == WHITE ? (line[10]>'0'+size-size/3 || line[12]>'0'+size-size/3)\r
- : (line[10] <= '0'+size/3 || line[12] <= '0'+size/3)) && line[13] != '+')\r
- line[13] = '=', line[14] = 0;\r
- }\r
- }\r
- if(line[9] == 'e' && (line[14] == 'a' || line[14] == 'h')) // seirawan castling + gating at Rook\r
- line[9] = line[14], line[11] = 'e'; // convert to RxK notation\r
+ Move4GUI(line+9);\r
printf("move %s\n", line+9); // send move to GUI\r
if(lastScore == 100001 && iniPos[0] != 'f') { printf("%s {mate}\n", stm == WHITE ? "1-0" : "0-1"); computer = NONE; }\r
stm = WHITE+BLACK - stm;\r
}\r
\r
void\r
+Move4Engine(char *m)\r
+{\r
+ if(sc == 's') {\r
+ // convert input move to USI format\r
+ if(m[1] == '@') { // drop\r
+ m[1] = '*';\r
+ } else {\r
+ m[0] = 'a'+'0'+size - m[0];\r
+ m[1] = 'a'+'0'+size - m[1];\r
+ }\r
+ m[2] = 'a'+'0'+size - m[2];\r
+ m[3] = 'a'+'0'+size - m[3];\r
+ if(m[4] == '=') m[4] = 0; // no '=' in USI format!\r
+ else if(m[4] != '\n') m[4] = '+'; // cater to WB 4.4 bug :-(\r
+ }\r
+ if(m[4] && (m[1] == '1' || m[1] == '8')) { // seirawan gating\r
+ m[5] = m[0], m[6] = m[1], m[7] = '\0'; // copy from-square behind it, as gating square\r
+ if(m[2] == 'e' && (m[0] == 'a' || m[0] == 'h'))\r
+ m[2] = (m[0]+m[2]+1)>>1, m[0] = 'e'; // gating at Rook\r
+ }\r
+}\r
+\r
+void\r
GUI2Engine()\r
{\r
char line[256], command[256], *p, *q;\r
Sync(PAUSE); // wait for readyok\r
}\r
else if(!strcmp(command, "usermove")) {\r
- if(sc == 's') {\r
- // convert input move to USI format\r
- if(line[10] == '@') { // drop\r
- line[10] = '*';\r
- } else {\r
- line[9] = 'a'+'0'+size - line[9];\r
- line[10] = 'a'+'0'+size - line[10];\r
- }\r
- line[11] = 'a'+'0'+size - line[11];\r
- line[12] = 'a'+'0'+size - line[12];\r
- if(line[13] == '=') line[13] = 0; // no '=' in USI format!\r
- else if(line[13] != '\n') line[13] = '+'; // cater to WB 4.4 bug :-(\r
- }\r
sscanf(line, "usermove %s", command); // strips off linefeed\r
- if(command[4] && (command[1] == '1' || command[1] == '8')) { // seirawan gating\r
- command[5] = command[0], command[6] = command[1], command[7] = '\0';\r
- if(command[2] == 'e' && (command[0] == 'a' || command[0] == 'h'))\r
- command[2] = (command[0]+command[2]+1)>>1, command[0] = 'e'; // gating at Rook\r
- }\r
+ Move4Engine(command);\r
stm = WHITE+BLACK - stm;\r
// when pondering we either continue the ponder search as normal search, or abort it\r
if(pondering || computer == ANALYZE) {\r
}\r
StopPonder(1);\r
}\r
-// sscanf(line, "usermove %s", move[moveNr++]); // possibly overwrites ponder move\r
- strcpy(move[moveNr++], command);\r
+ strcpy(move[moveNr++], command); // possibly overwrites ponder move\r
}\r
else if(!strcmp(command, "level")) {\r
int sec = 0;\r