Add setting up of holdings in variant seirawan
authorH.G. Muller <h.g.muller@hccnet.nl>
Tue, 27 Dec 2011 14:02:30 +0000 (15:02 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Tue, 27 Dec 2011 14:05:43 +0000 (15:05 +0100)
In WB edit mode lines of the form P@N put N copies of piece type P
in the Seirawan holdings, and the xedit=1 feature lets WB send it
this way. Should not be used for other pieces than H or E!

fairymax.c

index c68ca20..83002e5 100644 (file)
@@ -608,7 +608,7 @@ int main(int argc, char **argv)
                 if (!strcmp(command, "protover")) {\r
                         printf("feature myname=\"" NAME " " VERSION "\"\n");\r
                         printf("feature memory=1\n");\r
-                        printf("feature setboard=0 ping=1 done=0\n");\r
+                        printf("feature setboard=0 xedit=1 ping=1 done=0\n");\r
                         printf("feature variants=\"");\r
                         PrintVariants(0);\r
                         printf("\"\n");\r
@@ -815,11 +815,18 @@ int main(int argc, char **argv)
                                         Q = -Q;\r
                                         continue;\r
                                 }\r
-                                if( m >= 'A' && m <= 'Z' && piecetype[m&31]\r
-                                    && line[1] >= 'a' && line[1] <= 'a'+BW-1\r
+                                if( m >= 'A' && m <= 'Z' && piecetype[m&31]) {\r
+                                    p = (color == WHITE ? piecetype : blacktype)[line[0]&31];\r
+                                    if(line[1] == '@') { // stuff holdings\r
+                                        pl[color+p+5] = m = line[2] - '0';\r
+                                        pl[BLACK+WHITE-color]+=m;pl[p+color]+=m;\r
+                                        Q+=m*w[p]; R+=m*(w[p]/FAC);\r
+                                        continue;\r
+                                    } else\r
+                                    if(line[1] >= 'a' && line[1] <= 'a'+BW-1\r
                                     && line[2] >= '1' && line[2] <= '0'+BH) {\r
                                         m = line[1]-16*line[2]+799;\r
-                                        switch(p = (color == WHITE ? piecetype : blacktype)[line[0]&31])\r
+                                        switch(p)\r
                                         {\r
                                         case 1:\r
                                         case 2:\r
@@ -843,6 +850,7 @@ int main(int argc, char **argv)
                                         pl[BLACK+WHITE-color]++;pl[p+color]++;\r
                                         if(w[p+color] == -1)pl[p+color]=1; // fake we have one if value = -1, to thwart extinction condition\r
                                         continue;\r
+                                    }\r
                                 }\r
                         }\r
                         if(Side != color) Q = -Q;\r