Get rid of cxx/rxx in favor of COL/ROW_NAME.
authorYann Dirson <ydirson@free.fr>
Sat, 25 Jan 2014 20:58:52 +0000 (21:58 +0100)
committerYann Dirson <ydirson@free.fr>
Sat, 25 Jan 2014 20:58:52 +0000 (21:58 +0100)
There is nothing to gain with the string-based move conversion, which
adds move dependency on the game variant.  And nothing to gain either from
using 2 mechanisms for the same thing :)

gnushogi/book.c
gnushogi/commondsp.c
gnushogi/gnushogi.h
gnushogi/makepattern.c

index 5a331c9..6bf2af9 100644 (file)
@@ -117,8 +117,8 @@ Balgbr(short f, short t, short flag)
             short piece = flag & pmask;
             bmvstr[0][0] = pxx[piece];
             bmvstr[0][1] = '*';
-            bmvstr[0][2] = cxx[column(t)];
-            bmvstr[0][3] = rxx[row(t)];
+            bmvstr[0][2] = COL_NAME(column(t));
+            bmvstr[0][3] = ROW_NAME(row(t));
             bmvstr[0][4] = bmvstr[2][0] = '\0';
             strcpy(bmvstr[1], bmvstr[0]);
             bmvstr[1][1] = '\'';
@@ -130,10 +130,10 @@ Balgbr(short f, short t, short flag)
                 /* algebraic notation */
                 /* bmvstr[0]: 7g7f bmvstr[1]:
                  * (+)P7g7f(+) bmvstr[2]: (+)P7f(+) */
-                bmvstr[0][0] = cxx[column(f)];
-                bmvstr[0][1] = rxx[row(f)];
-                bmvstr[0][2] = cxx[column(t)];
-                bmvstr[0][3] = rxx[row(t)];
+                bmvstr[0][0] = COL_NAME(column(f));
+                bmvstr[0][1] = ROW_NAME(row(f));
+                bmvstr[0][2] = COL_NAME(column(t));
+                bmvstr[0][3] = ROW_NAME(row(t));
                 bmvstr[0][4] = '\0';
 
                 if (promoted)
index ab11cff..90a3ca0 100644 (file)
@@ -94,20 +94,20 @@ movealgbr(short m, char *s)
         s++;
         *s = '*';
         s++;
-        *s = cxx[column(t)];
+        *s = COL_NAME(column(t));
         s++;
-        *s = rxx[row(t)];
+        *s = ROW_NAME(row(t));
         s++;
     }
     else
     {
-        *s = cxx[column(f)];
+        *s = COL_NAME(column(f));
         s++;
-        *s = rxx[row(f)];
+        *s = ROW_NAME(row(f));
         s++;
-        *s = cxx[column(t)];
+        *s = COL_NAME(column(t));
         s++;
-        *s = rxx[row(t)];
+        *s = ROW_NAME(row(t));
         s++;
 
         if (flag & promote)
@@ -182,8 +182,8 @@ algbr(short f, short t, short flag)
 
         mvstr[0][0] = pxx[piece];
         mvstr[0][1] = '*';
-        mvstr[0][2] = cxx[column(t)];
-        mvstr[0][3] = rxx[row(t)];
+        mvstr[0][2] = COL_NAME(column(t));
+        mvstr[0][3] = ROW_NAME(row(t));
         mvstr[0][4] = '\0';
         strcpy(mvstr[1], mvstr[0]);
         strcpy(mvstr[2], mvstr[0]);
@@ -192,10 +192,10 @@ algbr(short f, short t, short flag)
     else if ((f != 0) || (t != 0))
     {
         /* pure coordinates notation */
-        mvstr[0][0] = cxx[column(f)];
-        mvstr[0][1] = rxx[row(f)];
-        mvstr[0][2] = cxx[column(t)];
-        mvstr[0][3] = rxx[row(t)];
+        mvstr[0][0] = COL_NAME(column(f));
+        mvstr[0][1] = ROW_NAME(row(f));
+        mvstr[0][2] = COL_NAME(column(t));
+        mvstr[0][3] = ROW_NAME(row(t));
         mvstr[0][4] = '\0';
 
         /* algebraic notation without disambiguation */
index 6429d1b..29d9abe 100644 (file)
@@ -326,13 +326,9 @@ enum {
 #ifndef MINISHOGI
 #define pxx (" PLNSGBRPLNSBRK ")
 #define qxx (" plnsgbrplnsbrk ")
-#define rxx ("ihgfedcba")
-#define cxx ("987654321")
 #else
 #define pxx (" PSGBRPSBRK ")
 #define qxx (" psgbrpsbrk ")
-#define rxx ("edcba")
-#define cxx ("54321")
 #endif
 
 /***************** Table limits ********************************************/
index 6dbca38..ef1a937 100644 (file)
@@ -124,7 +124,7 @@ ScanPiece(char **s, small_short *side,
         /* determine column */
         for (c = 0; c < NO_COLS; c++)
         {
-            if (**s == cxx[c])
+            if (**s == COL_NAME(c))
             {
                 (*s)++;
                 break;
@@ -137,7 +137,7 @@ ScanPiece(char **s, small_short *side,
         /* determine row */
         for (r = 0; r < NO_ROWS; r++)
         {
-            if (**s == rxx[r])
+            if (**s == ROW_NAME(r))
             {
                 (*s)++;
                 break;