Make variants also accessible through systematic names
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 28 Dec 2016 14:17:18 +0000 (15:17 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 28 Dec 2016 15:34:56 +0000 (16:34 +0100)
The engine-defined variants are now also announced as 5x5+5_shogi etc.,
and such names are matched based on the board parameters in the variant-
definition table.

dropper.c

index 726c1e8..31df0fa 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -416,9 +416,12 @@ void
 GameInit (char *name)
 {
     int v, *ip, i, color, r, f, zone;
-    unsigned char *moves, *codes;
+    unsigned char *moves, *codes; char c;
 
     // determine variant parameters
+    if(sscanf(name, "%dx%d+%d_%c", &f, &r, &i, &c) == 4) {
+       for(v=6; --v>0; ) if(variants[v].files == f && variants[v].ranks == r && variants[v].hand == i) break;
+    } else
     for(v=6; --v>0;) if(!strcmp(name, variants[v].name)) break;
 printf("# variant %d: %s\n", v, variants[v].name);
     nrFiles = variants[v].files;
@@ -1490,7 +1493,8 @@ printf("# command: %s\n", inBuf);
     }
     if(!strcmp(command, "protover")){
       printf("feature ping=1 setboard=1 colors=0 usermove=1 memory=1 debug=1 reuse=0 sigint=0 sigterm=0 myname=\"CrazyWa " VERSION "\"\n");
-      printf("feature variants=\"crazyhouse,shogi,minishogi,judkinshogi,torishogi,euroshogi,crazywa\"\n");
+      printf("feature variants=\"crazyhouse,shogi,minishogi,judkinshogi,torishogi,euroshogi,crazywa,"
+                               "5x5+5_shogi,6x6+6_shogi,7x7+6_shogi,11x11+16_shogi,8x8+6_crazyhouse,8x8+7_crazyhouse\"\n");
       printf("feature option=\"Resign -check 0\"\n");           // example of an engine-defined option
       printf("feature option=\"Contempt -spin 0 -200 200\"\n"); // and another one
       printf("feature done=1\n");