char fireMask;\r
} UndoInfo;\r
\r
-char *array, *reason;\r
+char *array, fenArray[4000], *reason;\r
int bWidth, bHeight, bsize, zone, currentVariant;\r
int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, chuFlag=1, tenFlag, mobilityScore;\r
int nodes, startTime, tlim1, tlim2, repCnt, comp;\r
for(i=0; ; i++) {\r
//printf("next rank: %s\n", array);\r
for(j = BW*i; ; j++) {\r
+ int pflag=0;\r
+ if(*array == '+') pflag++, array++;\r
c = name[0] = *array++;\r
if(!c) goto eos;\r
if(c == '.') continue;\r
if(name[1]) name[1] += 'A' - 'a';\r
} else color = WHITE;\r
p1 = LookUp(name, var);\r
+ if(pflag && p1->promoted) p1 = LookUp(p1->promoted, var); // use promoted piece instead\r
n = AddPiece(color, p1);\r
p[n].pos = j;\r
- if(p1->promoted[0]) {\r
+ if(p1->promoted[0] && !pflag) {\r
p2 = LookUp(p1->promoted, var);\r
m = AddPiece(color, p2);\r
if(m <= n) n += 2;\r
sup2 = sup1; sup1 = sup0;\r
}\r
\r
+char fenNames[] = "RV....DKDEFL..DHGB......SMLNKN..FK....BT..VM..PH...."; // 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(isalpha(*fen)) {\r
+ char *table = fenNames;\r
+ n = *fen > 'Z' ? 'a' - 'A' : 0;\r
+ if(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
+ fen++;\r
+ }\r
+ printf("# converted FEN '%s'\n", fenArray);\r
+ return fenArray;\r
+}\r
+\r
int\r
Setup2 (char *fen)\r
{\r
+ int stm = WHITE;\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
SetUp(array, currentVariant);\r
sup0 = sup1 = sup2 = ABSENT;\r
- rootEval = cnt50 = hashKeyH = hashKeyL = 0;\r
- return WHITE;\r
+ rootEval = cnt50 = hashKeyH = hashKeyL = moveNr = 0;\r
+ return stm;\r
}\r
\r
void\r