14 static const bool UseDebug = false;
\r
19 option_t Option[] = {
\r
21 { "OptionFile", "string","0","0", "polyglot.ini", NULL,0,{}, PG},
\r
25 { "EngineName", "string","0","0", "<empty>" , NULL,0,{}, PG},
\r
26 { "EngineDir", "string","0","0", "." , NULL,0,{}, PG},
\r
27 { "EngineCommand", "string","0","0", "<empty>" , NULL,0,{}, PG},
\r
29 { "Log", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI},
\r
30 { "LogFile", "string","0","0", "polyglot.log", NULL,0,{}, PG|XBOARD|UCI},
\r
32 { "UCI", "string","0","0", "false" , NULL,0,{}, PG},
\r
34 { "UseNice", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI},
\r
35 { "NiceValue", "spin", "0","20", "5" , NULL,0,{}, PG|XBOARD|UCI},
\r
37 { "Chess960", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
39 { "Resign", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
40 { "ResignMoves", "spin","0","10000", "3" , NULL,0,{}, PG|XBOARD},
\r
41 { "ResignScore", "spin","0","10000", "600" , NULL,0,{}, PG|XBOARD},
\r
43 { "MateScore", "spin","0","1000000", "10000" , NULL,0,{}, PG|XBOARD},
\r
45 { "Book", "check","0","0", "false" , NULL,0,{}, PG|XBOARD|UCI},
\r
46 { "BookFile", "string","0","0", "book.bin" , NULL,0,{}, PG|XBOARD|UCI},
\r
48 { "BookRandom", "check","0","0", "true" , NULL,0,{}, PG|XBOARD|UCI},
\r
49 { "BookLearn", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
51 { "KibitzMove", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
52 { "KibitzPV", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
54 { "KibitzCommand", "string","0","0", "tellall" , NULL,0,{}, PG|XBOARD},
\r
55 { "KibitzDelay", "check","0","10000", "5" , NULL,0,{}, PG|XBOARD},
\r
57 { "ShowPonder", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
61 { "UCIVersion", "spin","1","2", "2" , NULL,0,{}, PG|XBOARD},
\r
62 { "CanPonder", "check","1","2", "false" , NULL,0,{}, PG|XBOARD},
\r
63 { "SyncStop", "check","1","2", "false" , NULL,0,{}, PG|XBOARD},
\r
64 { "Affinity", "spin","-1","32", "-1" , NULL,0,{}, PG},
\r
65 { "RepeatPV", "check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
66 { "PromoteWorkAround","check","0","0", "false" , NULL,0,{}, PG|XBOARD},
\r
68 { NULL, NULL,"0","0", NULL , NULL,0,{}, 0},
\r
73 static option_t * option_find (const char var[]);
\r
79 void option_init() {
\r
84 while((name=(p++)->name)){
\r
85 option_set(name,option_get_default(name));
\r
92 bool option_set(const char name[], const char value[]) {
\r
96 ASSERT(value!=NULL);
\r
98 opt = option_find(name);
\r
99 if (opt == NULL) return false;
\r
101 my_string_set(&opt->value,value);
\r
103 if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
109 bool option_set_default(const char name[], const char value[]) {
\r
112 ASSERT(name!=NULL);
\r
113 ASSERT(value!=NULL);
\r
115 opt = option_find(name);
\r
116 if (opt == NULL) return false;
\r
118 opt->default_=my_strdup(value);
\r
120 if (UseDebug) my_log("POLYGLOT OPTION DEFAULT SET \"%s\" -> \"%s\"\n",opt->name,opt->default_);
\r
127 const char * option_get(const char name[]) {
\r
131 ASSERT(name!=NULL);
\r
133 opt = option_find(name);
\r
134 if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);
\r
136 if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
141 // option_get_default()
\r
143 const char * option_get_default(const char name[]) {
\r
147 ASSERT(name!=NULL);
\r
149 opt = option_find(name);
\r
150 if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",name);
\r
152 if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->name,opt->value);
\r
154 return opt->default_;
\r
157 // option_get_bool()
\r
159 bool option_get_bool(const char name[]) {
\r
161 const char * value;
\r
163 value = option_get(name);
\r
166 } else if (my_string_case_equal(value,"true") || my_string_case_equal(value,"yes") || my_string_equal(value,"1")) {
\r
168 } else if (my_string_case_equal(value,"false") || my_string_case_equal(value,"no") || my_string_equal(value,"0")) {
\r
177 // option_get_double()
\r
179 double option_get_double(const char name[]) {
\r
181 const char * value;
\r
183 value = option_get(name);
\r
185 return atof(value);
\r
188 // option_get_int()
\r
190 int option_get_int(const char name[]) {
\r
192 const char * value;
\r
194 value = option_get(name);
\r
196 return atoi(value);
\r
199 // option_get_string()
\r
201 const char * option_get_string(const char name[]) {
\r
203 const char * value;
\r
205 value = option_get(name);
\r
212 static option_t * option_find(const char name[]) {
\r
216 ASSERT(name!=NULL);
\r
219 for (opt = &Option[0]; opt->name != NULL; opt++) {
\r
220 if (my_string_case_equal(opt->name,name)) return opt;
\r
226 // end of option.cpp
\r