Save total material with setup position
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 12:09:34 +0000 (13:09 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 12:09:34 +0000 (13:09 +0100)
The total-material counter R, which determines the game stage, was not
saved with a setup position, so that 'undo' could mess it up. The piece
counters for each side, in pl[], are now saved in a loop, rather than
just the WHITE and BLACK element, and is extended to 32 elements.

fairymax.c

index 3b2db59..35d785b 100644 (file)
@@ -101,7 +101,7 @@ char *inifile = INI_FILE;
 int Ticks, tlim, Setup, SetupQ;\r
 \r
 int GameHistory[1024];\r
-char HistoryBoards[1024][STATE], setupPosition[131];\r
+char HistoryBoards[1024][STATE], setupPosition[162];\r
 int GamePtr, HistPtr;\r
 \r
 #define W while\r
@@ -119,7 +119,7 @@ oo[32],                                        /* initial piece setup      */
 of[256],\r
 od[16];                                        /* 1st dir. in o[] per piece*/\r
 \r
-signed char L,pl[17],\r
+signed char L,pl[32],\r
 b[513],                                        /* board: 16x8+dummy, + PST */\r
 T[4104],                                       /* hash translation table   */\r
 centr[32],\r
@@ -735,9 +735,9 @@ int main(int argc, char **argv)
                         InitGame();\r
                        if(Setup) {\r
                            for(i=0; i<128; i++) b[i] = setupPosition[i];\r
+                           for(i=0; i<32; i++) pl[i] = setupPosition[i+130];\r
                            Side = setupPosition[128]; Q = SetupQ;\r
-                           pl[WHITE] = setupPosition[129];\r
-                           pl[BLACK] = setupPosition[130];\r
+                           R = setupPosition[129];\r
                        }\r
                        for(i=0; i<=U; i++) A[i].D = A[i].K = 0; // clear hash table\r
                         for(nr=0; nr<GamePtr; nr++) {\r
@@ -812,8 +812,8 @@ int main(int argc, char **argv)
                        GamePtr = HistPtr = 0; Setup = 1; SetupQ = Q; // start anew\r
                        for(i=0; i<128; i++) setupPosition[i] = b[i]; // remember position\r
                        setupPosition[128] = Side;\r
-                       setupPosition[129] = pl[WHITE];\r
-                       setupPosition[130] = pl[BLACK];\r
+                       setupPosition[129] = R;\r
+                       for(i=0; i<32; i++) setupPosition[i+130] = pl[i];\r
                        continue;\r
                }\r
                 /* command not recognized, assume input move */\r