Allow sub-specification of variant fairy
[fairymax.git] / fairymax.c
index 6305a44..d02f86a 100644 (file)
@@ -95,6 +95,7 @@ int Score;
 int makruk;\r
 int prom;\r
 char piecename[32], piecetype[32], blacktype[32];\r
+char selectedFairy[80];\r
 char *inifile = INI_FILE;\r
 \r
 int Ticks, tlim, Setup, SetupQ;\r
@@ -387,9 +388,9 @@ void CopyBoard(int s)
             HistoryBoards[s][BW*i+j] = b[16*i+j]|64*(16*i+j==O);\r
 }\r
                                          \r
-void PrintVariants()\r
+void PrintVariants(int combo)\r
 {\r
-        int i, j, count=0; char c, buf[80];\r
+        int i, j, count=0, total=0; char c, buf[80];\r
         FILE *f;\r
 \r
         f = fopen(INI_FILE, "r");\r
@@ -400,11 +401,15 @@ void PrintVariants()
            while(fscanf(f, "Game: %s", buf) != 1 && c != EOF) \r
                while((c = fgetc(f)) != EOF && c != '\n');\r
            if(c == EOF) break;\r
-           if(count++) printf(",");\r
-           printf("%s", buf);\r
+           total++;\r
+           if(combo == (strstr(buf, "fairy/") != buf)) continue;\r
+           if(combo && count == 0) strcpy(selectedFairy, buf);\r
+           if(count++) printf(combo ? " /// " : ",");\r
+           printf("%s", combo ? buf+6 : buf);\r
         } while(c != EOF);\r
 \r
         fclose(f);\r
+        if(!combo && total != count) printf("%sfairy", count ? "," : "");\r
 }\r
 \r
 void PrintOptions()\r
@@ -413,9 +418,9 @@ void PrintOptions()
        printf("feature option=\"Resign Threshold -spin %d 200 1200\"\n", Threshold);\r
        printf("feature option=\"Ini File -file %s\"\n", inifile);\r
        printf("feature option=\"Multi-PV Margin -spin %d 0 1000\"\n", margin);\r
-       printf("feature option=\"Playing Style ;-) -combo Brilliant /// *Brave /// Beautiful\"\n");\r
+       printf("feature option=\"Variant fairy selects -combo "); PrintVariants(1); printf("\"\n");\r
        printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n");\r
-       printf("feature option=\"Dummy String Example -file happy birthday!\"\n");\r
+       printf("feature option=\"Dummy String Example -string happy birthday!\"\n");\r
        printf("feature option=\"Dummy Path Example -path .\"\n");\r
        printf("feature option=\"Clear Hash -button\"\n");\r
        printf("feature done=1\n");\r
@@ -437,6 +442,7 @@ int LoadGame(char *name)
 \r
         if(name != NULL)\r
         {  /* search for game name in definition file */\r
+           if(!strcmp(name, "fairy")) name = selectedFairy;\r
            while(fscanf(f, "Game: %s", buf)!=1 || strcmp(name, buf) ) {\r
                while((c = fgetc(f)) != EOF && c != '\n');\r
                count++;\r
@@ -569,7 +575,7 @@ int main(int argc, char **argv)
                         printf("feature memory=1\n");\r
                         printf("feature setboard=0 ping=1 done=0\n");\r
                         printf("feature variants=\"");\r
-                        PrintVariants();\r
+                        PrintVariants(0);\r
                         printf("\"\n");\r
                        PrintOptions();\r
                         continue;\r
@@ -693,6 +699,7 @@ int main(int argc, char **argv)
                        }\r
                        if(sscanf(line+7, "Clear Hash") == 1) for(i=0; i<U; i++) A->K = 0;\r
                        if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue;\r
+                       if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue;\r
                        continue;\r
                }\r
                if (!strcmp(command, "go")) {\r