Fix setboard command
[hachu.git] / hachu.c
diff --git a/hachu.c b/hachu.c
index 5c1a77b..a4c6bcb 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -11,7 +11,7 @@
 // promotions by pieces with Lion power stepping in & out the zone in same turn\r
 // promotion on capture\r
 \r
-#define VERSION "0.4beta"\r
+#define VERSION "0.5beta"\r
 \r
 #define PATH level==0 || path[0] == 0xc4028 &&  (level==1 /*|| path[1] == 0x75967 && (level == 2 || path[2] == 0x3400b && (level == 3))*/)\r
 //define PATH 0\r
@@ -327,12 +327,12 @@ PieceDesc chessPieces[] = {
 };\r
 \r
 PieceDesc shatranjPieces[] = {\r
-  {"Q", "",  15, { 0,1,0,1,0,1,0,1 } },\r
+  {"FK", "", 15, { 0,1,0,1,0,1,0,1 } },\r
   {"R", "",  50, { X,0,X,0,X,0,X,0 } },\r
   {"B", "",   9, { 0,J,0,J,0,J,0,J } },\r
   {"N", "",  30, { N,N,N,N,N,N,N,N } },\r
   {"K", "",  28, { 1,1,1,1,1,1,1,1 } },\r
-  {"P", "Q",  8, { M,C,0,0,0,0,0,C } },\r
+  {"P", "FK", 8, { M,C,0,0,0,0,0,C } },\r
   { NULL }  // sentinel\r
 };\r
 \r
@@ -349,7 +349,7 @@ char tenArray[] = "LN:FLICSGK:DEGSCI:FLNL/:RV.:CS:CS.:BT:KN:LN:FK:PH:BT.:CS:CS.:
                  ":ss:vsb:dh:dk:wb:fi:fe:lh:fi:wb:dk:dhb:vs:ss/:rv.:cs:cs.:bt:ph:fk:ln:kn:bt.:cs:cs.:rv/ln:flicsg:dekgsci:flnl";\r
 char shoArray[] = "LNSGKGSNL/.B..:DE..R./PPPPPPPPP/........./........./........./ppppppppp/.r..:de..b./lnsgkgsnl";\r
 char chessArray[] = "RNBQKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbqkbnr";\r
-char shatArray[]= "RNBKQBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbkqbnr";\r
+char shatArray[]= "RNBK:FKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbk:fkbnr";\r
 \r
 typedef struct {\r
   int boardWidth, boardFiles, boardRanks, zoneDepth, varNr; // board sizes\r
@@ -1909,7 +1909,7 @@ Convert (char *fen)
     if(isalpha(*fen)) {\r
       char *table = fenNames;\r
       n = *fen > 'Z' ? 'a' - 'A' : 0;\r
-      if((currentVariant == V_CHESS || currentVariant == V_SHATRANJ) && *fen - 'A' - n == 'N' // In Chess N is Knight, not Lion\r
+      if((currentVariant == V_CHESS || currentVariant == V_SHATRANJ) && *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
@@ -2143,7 +2143,7 @@ printf("# setup done");fflush(stdout);
       int timeLeft;                            // timeleft on engine's clock\r
       int mps, timeControl, inc, timePerMove;  // time-control parameters, to be used by Search\r
       MOVE move, ponderMove;\r
-      int i, score;\r
+      int i, score, curVarNr;\r
       char inBuf[8000], command[80];\r
 \r
   Init(V_CHU); // Chu\r
@@ -2238,7 +2238,7 @@ printf("in: %s\n", command);
           for(i=0; i<6; i++) {\r
             sscanf(inBuf+8, "%s", command);\r
             if(!strcmp(variants[i].name, command)) {\r
-              Init(i); stm = Setup2(NULL); break;\r
+              Init(curVarNr = i); stm = Setup2(NULL); break;\r
             }\r
          }\r
           continue;\r
@@ -2249,10 +2249,10 @@ printf("in: %s\n", command);
         if(!strcmp(command, "ping"))    { printf("pong%s", inBuf+4); continue; }\r
     //  if(!strcmp(command, ""))        { sscanf(inBuf, " %d", &); continue; }\r
         if(!strcmp(command, "new"))     {\r
-          engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; comp = 0;\r
+          engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0;\r
           continue;\r
         }\r
-        if(!strcmp(command, "setboard")){ engineSide = NONE;  Init(currentVariant); stm = Setup2(inBuf+9); continue; }\r
+        if(!strcmp(command, "setboard")){ engineSide = NONE;  Init(curVarNr); stm = Setup2(inBuf+9); continue; }\r
         if(!strcmp(command, "easy"))    { ponder = OFF; continue; }\r
         if(!strcmp(command, "hard"))    { ponder = ON;  continue; }\r
         if(!strcmp(command, "undo"))    { stm = TakeBack(1); continue; }\r