Make repetitions in Chess and Shatranj draws
[hachu.git] / hachu.c
diff --git a/hachu.c b/hachu.c
index 173aae9..5c1a77b 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -92,7 +92,7 @@ typedef struct {
 } UndoInfo;\r
 \r
 char *array, fenArray[4000], *reason;\r
-int bWidth, bHeight, bsize, zone, currentVariant, chuFlag, tenFlag, chessFlag;\r
+int bWidth, bHeight, bsize, zone, currentVariant, chuFlag, tenFlag, chessFlag, repDraws;\r
 int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, mobilityScore;\r
 int nodes, startTime, tlim1, tlim2, repCnt, comp;\r
 Move retMove, moveStack[10000], path[100], repStack[300], pv[1000], repeatMove[300];\r
@@ -676,7 +676,7 @@ AddPiece (int stm, PieceDesc *list)
     if(p[j].promo >= i) p[j].promo += 2;\r
   }\r
   if(royal[stm] >= i) royal[stm] += 2;\r
-  if(p[i].value == (currentVariant == V_SHO ? 410 : 280) ) royal[stm] = i;\r
+  if(p[i].value == (currentVariant == V_SHO ? 410 : 280) ) royal[stm] = i, p[i].pst = 0;\r
   p[i].qval = (currentVariant == V_TENJIKU ? list->ranking : 0); // jump-capture hierarchy\r
   return i;\r
 }\r
@@ -761,6 +761,7 @@ Init (int var)
   chuFlag = (currentVariant == V_CHU);\r
   tenFlag = (currentVariant == V_TENJIKU);\r
   chessFlag = (currentVariant == V_CHESS);\r
+  repDraws  = (currentVariant == V_CHESS || currentVariant == V_SHATRANJ);\r
 \r
   for(i= -1; i<9; i++) { // board steps in linear coordinates\r
     kStep[i] = STEP(direction[i&7].x,   direction[i&7].y);       // King\r
@@ -1667,6 +1668,7 @@ if(flag & depth >= 0) printf("%2d:%d found %d/%d %08x %s\n", depth, iterDep, cur
 \r
 if(flag & depth >= 0) printf("%2d:%d made %d/%d %s\n", depth, iterDep, curMove, msp, MoveToText(moveStack[curMove], 0));\r
       for(i=2; i<=cnt50; i+=2) if(repStack[level-i+200] == hashKeyH) {\r
+       if(repDraws) { score = 0; goto repetition; }\r
        moveStack[curMove] = 0; // erase forbidden move\r
        if(!level) repeatMove[repCnt++] = move & 0xFFFFFF; // remember outlawed move\r
        score = -INF; moveStack[curMove] = 0; goto repetition;\r
@@ -2233,7 +2235,7 @@ printf("in: %s\n", command);
           continue;\r
         }\r
         if(!strcmp(command, "variant")) {\r
-          for(i=0; i<5; i++) {\r
+          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