Make reference to mini-Shogi symbolic
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 15:21:53 +0000 (17:21 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 16:16:42 +0000 (18:16 +0200)
I various parts of the code it was assumed that mini-Shogi was listed
as second variant in the variant-definition array. To make it easier
to reshuffle variants a macro MINI_NR, #defined close to the array,
makes it easier to shuffle the order of variants.

dropper.c

index 4bf5dff..eaea10c 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -400,8 +400,9 @@ VariantDesc variants[] = {
   {  7,  7,  6, 2, "torishogi\n",   toriIDs,  toriFEN,   toriDirs,  toriProms,  toriCodes,  toriValues  },
 };
 
-#define TORI_NR 7 /* must correspond to index of torishogi (which must be last) in table above! */
-#define KNIGHTLESS 4 /* first variant without a Knight (except mini-, which has no 2-rank zone) */
+#define TORI_NR  7 /* must correspond to index of torishogi (which must be last) in table above! */
+#define MINI_NR  1
+#define KNIGHTLESS 4  /* first variant without a Knight (except mini-, which has no 2-rank zone) */
 
 // info per piece type. sometimes indexed by negated holdings count instead of piece
 #define pieceKey   (rawKey+1)
@@ -491,7 +492,7 @@ GameInit (char *name)
        printf("\n");
     }
 
-    maxDrop += (v==2 || v==1); // Judkins & mini-Shogi have dummy Lance
+    maxDrop += (v==MINI_NR+1 || v==MINI_NR); // Judkins & mini-Shogi have dummy Lance
 
     // board
     ClearBoard();
@@ -578,7 +579,7 @@ GameInit (char *name)
     }
     for(r=0; r<zone; r++) { // board-size table to indicate promotion zones and force-promotion zones
        for(f=0; f<nrFiles; f++) {
-           int xr = nrRanks - 1 - r, c = Z_MUST | COLOR | (r==0)*Z_LAST | (r<2 && v!=1)*Z_2ND; // in mini-Shogi forelast not in zone
+           int xr = nrRanks - 1 - r, c = Z_MUST | COLOR | (r==0)*Z_LAST | (r<2 && v!=MINI_NR)*Z_2ND; // in mini-Shogi forelast not in zone
            zoneTab[22*r  + f] = Z_BLACK & c;
            zoneTab[22*xr + f] = Z_WHITE & c;
        }
@@ -1360,7 +1361,7 @@ Search (int stm, int alpha, int beta, StackFrame *ff, int depth, int reduction,
                            else {
                                for(i=moveNr+ply-2; i>=d; i-=2) if(checkHist[i+1] == CK_NONE) break;
                                if(i < d) score = INF-1; // we are suffering a perpetual, so lose
-                               else if(perpLoses == 1) score = (stm == WHITE ? -INF : INF-1); // mini-Shogi, sente loses
+                               else if(perpLoses == MINI_NR) score = (stm == WHITE ? -INF : INF-1); // mini-Shogi, sente loses
                                else if(perpLoses == TORI_NR) score = -INF; // Tori Shogi, repeating loses
                            }