sup2 = sup1; sup1 = sup0;\r
}\r
\r
-char fenNames[] = "RV....DKDEFL..DHGB......SMLNKN..FK....BT..VMEWPH..LN"; // pairs of char\r
-char fenPromo[] = "WLDHSMSECPB R HFDE....WHFB..LNG ..DKVMFS..FO..FK...."; // pairs of char\r
-\r
-char *\r
-Convert (char *fen)\r
-{\r
- char *p = fenArray, *q, *rows[36], tmp[4000];\r
- int n=0;\r
- printf("# convert FEN '%s'\n", fen);\r
- q = strchr(fen, ' '); if(q) *q = 0; q = fen;\r
- do { rows[n++] = q; q = strchr(q, '/'); if(!q) break; *q++ = 0; } while(1);\r
- *tmp = 0;\r
- while(--n >= 0) { strcat(tmp, rows[n]); if(n) strcat(tmp, "/"); }\r
- fen = tmp;\r
- printf("# flipped FEN '%s'\n", fen);\r
- while(*fen) {\r
- if(*fen == ' ') { *p = 0; break; }\r
- if(n=atoi(fen)) fen++; // digits read\r
- if(n > 9) fen++; // double digit\r
- while(n-- > 0) *p++ = '.'; // expand to empty squares\r
- if(currentVariant == V_LION && (*fen == 'L' || *fen == 'l')) *fen += 'Z' - 'L'; // L in Mighty-Lion Chess changed in Z for Lion\r
- if(isalpha(*fen)) {\r
- char *table = fenNames;\r
- n = *fen > 'Z' ? 'a' - 'A' : 0;\r
- if((currentVariant == V_CHESS || currentVariant == V_SHATRANJ || currentVariant == V_LION || currentVariant == V_WOLF ||\r
- currentVariant == V_MAKRUK || currentVariant == V_SHO) && *fen - n == 'N' // In Chess N is Knight, not Lion\r
- || table[2* (*fen - 'A' - n)] == '.') *p++ = *fen; else {\r
- *p++ = ':';\r
- *p++ = table[2* (*fen - 'A' - n)] + n;\r
- *p++ = table[2* (*fen - 'A' - n)+1] + n;\r
- }\r
- } else *p++ = *fen;\r
- if(!*fen) break;\r
- fen++;\r
- }\r
- *p = '\0';\r
- printf("# converted FEN '%s'\n", fenArray);\r
- return fenArray;\r
-}\r
-\r
int\r
Setup2 (char *fen)\r
{\r
+ char *p;\r
int stm = WHITE;\r
+ static char startFEN[4000];\r
if(fen) {\r
char *q = strchr(fen, '\n');\r
if(q) *q = 0;\r
if(q = strchr(fen, ' ')) stm = (q[1] == 'b' ? BLACK : WHITE); // fen contains color field\r
- if(strchr(fen, '.') || strchr(fen, ':')) array = fen; else array = Convert(fen);\r
- }\r
+ } else fen = array;\r
rootEval = promoDelta = filling = cnt50 = moveNr = 0;\r
- SetUp(array, currentVariant);\r
- strcpy(startPos, array);\r
+ SetUp(fen, currentVariant);\r
sup0 = sup1 = sup2 = ABSENT;\r
hashKeyH = hashKeyL = 87620895*currentVariant + !!fen;\r
+ for(p=startPos; *p++ = *fen++; ) {} // remember last start position for undo\r
return stm;\r
}\r
\r