Leave move list of game position on stack permanently
[hachu.git] / hachu.c
diff --git a/hachu.c b/hachu.c
index a81f25f..2b89d21 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -2091,7 +2091,7 @@ MapFromScratch(attacks);
   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
+  listStart = retFirst; listEnd = msp = retMSP;\r
 }\r
 \r
 MOVE\r
@@ -2116,7 +2116,7 @@ ParseMove (char *moveText)
   ret = f<<SQLEN | t2;\r
   if(*moveText != '\n' && *moveText != '=') ret |= PROMOTE;\r
 printf("# suppress = %c%d\n", sup1%BW+'a', sup1/BW);\r
-  ListMoves();\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
@@ -2157,7 +2157,7 @@ Highlight(char *coords)
   char b[BSIZE], buf[2000], *q;\r
   for(i=0; i<bsize; i++) b[i] = 0;\r
   ReadSquare(coords, &sqr);\r
-  ListMoves();\r
+//  ListMoves();\r
   for(i=listStart; i<listEnd; i++) {\r
     if(sqr == (moveStack[i]>>SQLEN & SQUARE)) {\r
       int t = moveStack[i] & SQUARE;\r
@@ -2259,6 +2259,8 @@ printf("# setup done");fflush(stdout);
 \r
         fflush(stdout);                 // make sure everything is printed before we do something that might take time\r
 \r
+        if(listEnd == 0) ListMoves();   // always maintain a list of legal moves in root position\r
+\r
         if(stm == engineSide) {         // if it is the engine's turn to move, set it thinking, and let it move\r
      \r
 pboard(board);\r
@@ -2285,6 +2287,7 @@ pboard(board);
             stm = MakeMove2(stm, move);  // assumes MakeMove returns new side to move\r
             gameMove[moveNr++] = move;  // remember game\r
             printf("move %s\n", MoveToText(move, 1));\r
+            listEnd = 0;\r
           }\r
         }\r
 \r
@@ -2380,11 +2383,12 @@ pboard(board);
             if(comp) PrintResult(stm, -INF); // against computer: claim\r
           } else {\r
             stm = MakeMove2(stm, move);\r
-            ponderMove = INVALID;\r
+            ponderMove = INVALID; listEnd = 0;\r
             gameMove[moveNr++] = move;  // remember game\r
           }\r
           continue;\r
         }\r
+        listEnd = 0;\r
         if(!strcmp(command, "new"))     {\r
           engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0;\r
           continue;\r