return 2 + (r + ONE > 9);\r
}\r
\r
+int listStart, listEnd;\r
+char boardCopy[BSIZE];\r
+\r
+void\r
+ListMoves ()\r
+{ // create move list on move stack\r
+ int i;\r
+ for(i=0; i< BSIZE; i++) boardCopy[i] = !!board[i];\r
+MapFromScratch(attacks);\r
+ postThinking--; repCnt = 0; tlim1 = tlim2 = 1e8; msp = 0;\r
+ Search(-INF-1, INF+1, 0, 1, sup1 & ~PROMOTE, sup2);\r
+ postThinking++;\r
+ listStart = retFirst; listEnd = retMSP;\r
+}\r
+\r
MOVE\r
ParseMove (char *moveText)\r
{\r
ret = f<<SQLEN | t2;\r
if(*moveText != '\n' && *moveText != '=') ret |= PROMOTE;\r
printf("# suppress = %c%d\n", sup1%BW+'a', sup1/BW);\r
-MapFromScratch(attacks);\r
- postThinking--; repCnt = 0;\r
- Search(-INF-1, INF+1, 0, 1, sup1 & ~PROMOTE, sup2);\r
- postThinking++;\r
- for(i=retFirst; i<retMSP; i++) {\r
+ ListMoves();\r
+ for(i=listStart; i<listEnd; i++) {\r
if(moveStack[i] == INVALID) continue;\r
if(c == '@' && (moveStack[i] & SQUARE) == (moveStack[i] >> SQLEN & SQUARE)) break; // any null move matches @@@@\r
if((moveStack[i] & (PROMOTE | DEFER-1)) == ret) break;\r
if((moveStack[i] & DEFER-1) == ret) deferred = i; // promoted version of entered non-promotion is legal\r
}\r
-printf("# moveNr = %d in {%d,%d}\n", i, retFirst, retMSP);\r
- if(i>=retMSP) { // no exact match\r
+printf("# moveNr = %d in {%d,%d}\n", i, listStart, listEnd);\r
+ if(i>=listEnd) { // no exact match\r
if(deferred) { // but maybe non-sensical deferral\r
int flags = p[board[f]].promoFlag;\r
printf("# deferral of %d\n", deferred);\r
if(!(flags & promoBoard[f])) moveStack[i] |= DEFER; // came from outside zone, so essential deferral\r
}\r
}\r
- if(i >= retMSP) {\r
- for(i=retFirst; i<retMSP; i++) printf("# %d. %08x %08x %s\n", i-50, moveStack[i], ret, MoveToText(moveStack[i], 0));\r
+ if(i >= listEnd) {\r
+ for(i=listStart; i<listEnd; i++) printf("# %d. %08x %08x %s\n", i-50, moveStack[i], ret, MoveToText(moveStack[i], 0));\r
reason = NULL;\r
for(i=0; i<repCnt; i++) {if((repeatMove[i] & 0xFFFFFF) == ret) {\r
if(repeatMove[i] & 1<<24) reason = (repeatMove[i] & 1<<25 ? "Distant capture of protected Lion" : "Counterstrike against Lion");\r
}\r
}\r
}\r
- return (i >= retMSP ? INVALID : moveStack[i]);\r
+ return (i >= listEnd ? INVALID : moveStack[i]);\r
}\r
\r
void\r
char b[BSIZE], buf[2000], *q;\r
for(i=0; i<bsize; i++) b[i] = 0;\r
ReadSquare(coords, &sqr);\r
-MapFromScratch(attacks);\r
-//pmap(attacks, WHITE);\r
-//pmap(attacks, BLACK);\r
-//flag=1;\r
- postThinking--; repCnt = 0;\r
- Search(-INF-1, INF+1, 0, 1, sup1 & ~PROMOTE, sup2);\r
- postThinking++;\r
-flag=0;\r
- for(i=retFirst; i<retMSP; i++) {\r
+ ListMoves();\r
+ for(i=listStart; i<listEnd; i++) {\r
if(sqr == (moveStack[i]>>SQLEN & SQUARE)) {\r
int t = moveStack[i] & SQUARE;\r
if(t >= SPECIAL) continue;\r
- b[t] = (board[t] == EMPTY ? 'Y' : 'R'); cnt++;\r
+ b[t] = (!boardCopy[t] ? 'Y' : 'R'); cnt++;\r
}\r
}\r
if(!cnt) { // no moves from given square\r
if(sqr != lastPut) return; // refrain from sending empty FEN\r
// we lifted a piece for second leg of move\r
- for(i=retFirst; i<retMSP; i++) {\r
+ for(i=listStart; i<listEnd; i++) {\r
if(lastLift == (moveStack[i]>>SQLEN & SQUARE)) {\r
int e, t = moveStack[i] & SQUARE;\r
if(t < SPECIAL) continue; // only special moves\r
e = lastLift + epList[t - SPECIAL]; // decode\r
t = lastLift + toList[t - SPECIAL];\r
if(e != sqr) continue;\r
- b[t] = (board[t] == EMPTY ? 'Y' : 'R'); cnt++;\r
+ b[t] = (!boardCopy[t] ? 'Y' : 'R'); cnt++;\r
}\r
}\r
if(!cnt) return;\r