14 static const bool UseDebug = FALSE;
\r
19 #define NNB { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL }
\r
20 option_t Option[] = {
\r
22 { "OptionFile", "string","0","0", "polyglot.ini", NULL,0,NNB, PG},
\r
26 { "EngineName", "string","0","0", "<empty>" , NULL,0,NNB, PG},
\r
27 { "EngineDir", "string","0","0", "." , NULL,0,NNB, PG},
\r
28 { "EngineCommand", "string","0","0", "<empty>" , NULL,0,NNB, PG},
\r
30 { "Log", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI},
\r
31 { "LogFile", "string","0","0", "polyglot.log", NULL,0,NNB, PG|XBOARD|UCI},
\r
33 { "UCI", "check","0","0", "false" , NULL,0,NNB, PG},
\r
35 { "UseNice", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI},
\r
36 { "NiceValue", "spin", "0","20", "5" , NULL,0,NNB, PG|XBOARD|UCI},
\r
38 { "Chess960", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
40 { "Resign", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
41 { "ResignMoves", "spin","0","10000", "3" , NULL,0,NNB, PG|XBOARD},
\r
42 { "ResignScore", "spin","0","10000", "600" , NULL,0,NNB, PG|XBOARD},
\r
44 { "MateScore", "spin","0","1000000", "10000" , NULL,0,NNB, PG|XBOARD},
\r
46 { "Book", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI},
\r
47 { "BookFile", "string","0","0", "book.bin" , NULL,0,NNB, PG|XBOARD|UCI},
\r
49 { "BookRandom", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD|UCI},
\r
50 { "BookLearn", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
52 { "KibitzMove", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
53 { "KibitzPV", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
55 { "KibitzCommand", "string","0","0", "tellall" , NULL,0,NNB, PG|XBOARD},
\r
56 { "KibitzDelay", "spin","0","10000", "5" , NULL,0,NNB, PG|XBOARD},
\r
57 { "KibitzInterval", "spin","0","10000", "0" , NULL,0,NNB, PG|XBOARD},
\r
59 { "ShowPonder", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
60 { "ScoreWhite", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
64 { "UCIVersion", "spin","1","2", "2" , NULL,0,NNB, PG|XBOARD},
\r
65 { "CanPonder", "check","1","2", "false" , NULL,0,NNB, PG|XBOARD},
\r
66 { "SyncStop", "check","1","2", "false" , NULL,0,NNB, PG|XBOARD},
\r
67 { "Affinity", "spin","-1","32", "-1" , NULL,0,NNB, PG},
\r
68 { "RepeatPV", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD},
\r
69 { "PromoteWorkAround","check","0","0", "false" , NULL,0,NNB, PG|XBOARD},
\r
71 { NULL, NULL,"0","0", NULL , NULL,0,NNB, 0},
\r
76 static option_t * option_find (const char var[]);
\r
82 void option_init() {
\r
87 while((name=(p++)->name)){
\r
88 option_set(name,option_get_default(name));
\r
95 bool option_set(const char name[], const char value[]) {
\r
99 ASSERT(value!=NULL);
\r
101 opt = option_find(name);
\r
102 if (opt == NULL) return FALSE;
\r
104 my_string_set(&opt->value,value);
\r
106 if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
112 bool option_set_default(const char name[], const char value[]) {
\r
115 ASSERT(name!=NULL);
\r
116 ASSERT(value!=NULL);
\r
118 opt = option_find(name);
\r
119 if (opt == NULL) return FALSE;
\r
121 opt->default_=my_strdup(value);
\r
123 if (UseDebug) my_log("POLYGLOT OPTION DEFAULT SET \"%s\" -> \"%s\"\n",opt->name,opt->default_);
\r
130 const char * option_get(const char name[]) {
\r
134 ASSERT(name!=NULL);
\r
136 opt = option_find(name);
\r
137 if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);
\r
139 if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
144 // option_get_default()
\r
146 const char * option_get_default(const char name[]) {
\r
150 ASSERT(name!=NULL);
\r
152 opt = option_find(name);
\r
153 if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);
\r
155 if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
157 return opt->default_;
\r
160 // option_get_bool()
\r
162 bool option_get_bool(const char name[]) {
\r
164 const char * value;
\r
166 value = option_get(name);
\r
169 } else if (my_string_case_equal(value,"true") || my_string_case_equal(value,"yes") || my_string_equal(value,"1")) {
\r
171 } else if (my_string_case_equal(value,"false") || my_string_case_equal(value,"no") || my_string_equal(value,"0")) {
\r
180 // option_get_double()
\r
182 double option_get_double(const char name[]) {
\r
184 const char * value;
\r
186 value = option_get(name);
\r
188 return atof(value);
\r
191 // option_get_int()
\r
193 int option_get_int(const char name[]) {
\r
195 const char * value;
\r
197 value = option_get(name);
\r
199 return atoi(value);
\r
202 // option_get_string()
\r
204 const char * option_get_string(const char name[]) {
\r
206 const char * value;
\r
208 value = option_get(name);
\r
215 static option_t * option_find(const char name[]) {
\r
219 ASSERT(name!=NULL);
\r
222 for (opt = &Option[0]; opt->name != NULL; opt++) {
\r
223 if (my_string_case_equal(opt->name,name)) return opt;
\r
229 // end of option.cpp
\r