From: H.G. Muller Date: Mon, 1 Nov 2010 10:54:08 +0000 (+0100) Subject: Allow sub-specification of variant fairy X-Git-Tag: 4.8P~12 X-Git-Url: http://winboard.nl/cgi-bin?p=fairymax.git;a=commitdiff_plain;h=ac213a6bde534721fbea5d1cb0c8bf377238edce Allow sub-specification of variant fairy If game definitions in the fmax.ini file now have a name starting with "fairy/", they are not mentioned in the variants feature, but in stead the part after the '/' will appear in a combobox engine option for choosing the actual variant to play when the GUI says "fairy". --- diff --git a/data/fmax.ini b/data/fmax.ini index d6f70e1..b4e9440 100644 --- a/data/fmax.ini +++ b/data/fmax.ini @@ -392,7 +392,7 @@ m:-1 1,34 -1,34 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 16,70 -16,70 d:625 1,7 16,7 -1,7 -16,7 15,3 17,3 -15,3 -17,3 // Set for Chess with Different Armies, FIDE vs Color-bound Cloberers (legality-testing off!) -Game: fairy +Game: fairy/FIDE-Clobberers 8x8 6 4 5 7 3 5 4 6 11 9 10 12 8 10 9 11 diff --git a/fairymax.c b/fairymax.c index 6305a44..d02f86a 100644 --- a/fairymax.c +++ b/fairymax.c @@ -95,6 +95,7 @@ int Score; int makruk; int prom; char piecename[32], piecetype[32], blacktype[32]; +char selectedFairy[80]; char *inifile = INI_FILE; int Ticks, tlim, Setup, SetupQ; @@ -387,9 +388,9 @@ void CopyBoard(int s) HistoryBoards[s][BW*i+j] = b[16*i+j]|64*(16*i+j==O); } -void PrintVariants() +void PrintVariants(int combo) { - int i, j, count=0; char c, buf[80]; + int i, j, count=0, total=0; char c, buf[80]; FILE *f; f = fopen(INI_FILE, "r"); @@ -400,11 +401,15 @@ void PrintVariants() while(fscanf(f, "Game: %s", buf) != 1 && c != EOF) while((c = fgetc(f)) != EOF && c != '\n'); if(c == EOF) break; - if(count++) printf(","); - printf("%s", buf); + total++; + if(combo == (strstr(buf, "fairy/") != buf)) continue; + if(combo && count == 0) strcpy(selectedFairy, buf); + if(count++) printf(combo ? " /// " : ","); + printf("%s", combo ? buf+6 : buf); } while(c != EOF); fclose(f); + if(!combo && total != count) printf("%sfairy", count ? "," : ""); } void PrintOptions() @@ -413,9 +418,9 @@ void PrintOptions() printf("feature option=\"Resign Threshold -spin %d 200 1200\"\n", Threshold); printf("feature option=\"Ini File -file %s\"\n", inifile); printf("feature option=\"Multi-PV Margin -spin %d 0 1000\"\n", margin); - printf("feature option=\"Playing Style ;-) -combo Brilliant /// *Brave /// Beautiful\"\n"); + printf("feature option=\"Variant fairy selects -combo "); PrintVariants(1); printf("\"\n"); printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n"); - printf("feature option=\"Dummy String Example -file happy birthday!\"\n"); + printf("feature option=\"Dummy String Example -string happy birthday!\"\n"); printf("feature option=\"Dummy Path Example -path .\"\n"); printf("feature option=\"Clear Hash -button\"\n"); printf("feature done=1\n"); @@ -437,6 +442,7 @@ int LoadGame(char *name) if(name != NULL) { /* search for game name in definition file */ + if(!strcmp(name, "fairy")) name = selectedFairy; while(fscanf(f, "Game: %s", buf)!=1 || strcmp(name, buf) ) { while((c = fgetc(f)) != EOF && c != '\n'); count++; @@ -569,7 +575,7 @@ int main(int argc, char **argv) printf("feature memory=1\n"); printf("feature setboard=0 ping=1 done=0\n"); printf("feature variants=\""); - PrintVariants(); + PrintVariants(0); printf("\"\n"); PrintOptions(); continue; @@ -693,6 +699,7 @@ int main(int argc, char **argv) } if(sscanf(line+7, "Clear Hash") == 1) for(i=0; iK = 0; if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; + if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue; continue; } if (!strcmp(command, "go")) {