📄 config.cpp
字号:
// option.cpp
// includes
#include <cstdlib>
#include "config.h"
#include "interface.h"
// types
struct option_t
{
const char *var;
bool declare;
const char *init;
const char *type;
const char *extra;
const char *val;
};
// variables
static option_t Option [] =
{
{ "Bitbases", true, "true", "check", "", NULL },
{ "Bitbase Path", true, "c:/egbb/", "string", "", NULL },
{ "Bitbase Cache", true, "16", "spin", "min 16 max 1024", NULL },
{ "Ponder", true, "true", "check", "", NULL },
{ "Dynamic Hash", true, "true", "check", "", NULL },
{ "Nodes Per Second", true, "500000", "spin", "min 10000 max 10000000", NULL },
{ "Seconds Per Move", true, "5", "spin", "min 1 max 3600", NULL },
{ "Manual Hash", true, "false", "check", "", NULL },
{ "Manual Hash Size", true, "16", "spin", "min 8 max 1024", NULL },
{ "MultiPV", true, "1", "spin", "min 1 max 10", NULL },
{ "Search Time", true, "0", "spin", "min 0 max 3600", NULL },
{ "Search Depth", true, "0", "spin", "min 0 max 20", NULL },
{ "Threads", true, "1", "spin", "min 1 max 16", NULL },
{ NULL, false, NULL, NULL, NULL, NULL, },
};
// prototypes
static option_t *option_find(const char var []);
// functions
// option_init()
void option_init()
{
option_t *opt;
for ( opt = &Option[0]; opt->var != NULL; opt++ )
{
option_set(opt->var, opt->init);
}
}
// option_list()
void option_list()
{
option_t *opt;
for ( opt = &Option[0]; opt->var != NULL; opt++ )
{
if(opt->declare)
{
if(opt->extra != NULL && *opt->extra != '\0')
{
send("option name %s type %s default %s %s", opt->var, opt->type, opt->val, opt->extra);
}
else
{
send("option name %s type %s default %s", opt->var, opt->type, opt->val);
}
}
}
}
// option_set()
bool option_set(const char var [], const char val [])
{
option_t *opt;
opt = option_find(var);
if(opt == NULL)
return false;
string_set(&opt->val, val);
return true;
}
// option_get()
const char *option_get(const char var [])
{
option_t *opt;
opt = option_find(var);
return opt->val;
}
// option_get_bool()
bool option_get_bool(const char var [])
{
const char *val;
val = option_get(var);
if(false) { }
else if(string_equals(val, "true") || string_equals(val, "yes") || string_equals(val, "1"))
{
return true;
}
else if(string_equals(val, "false") || string_equals(val, "no") || string_equals(val, "0"))
{
return false;
}
return false;
}
// option_get_int()
int option_get_int(const char var [])
{
const char *val;
val = option_get(var);
return atoi(val);
}
// option_get_string()
const char *option_get_string(const char var [])
{
const char *val;
val = option_get(var);
return val;
}
// option_find()
static option_t *option_find(const char var [])
{
option_t *opt;
for ( opt = &Option[0]; opt->var != NULL; opt++ )
{
if(string_equals(opt->var, var))
return opt;
}
return NULL;
}
// end of option.cpp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -