1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
// option.cpp
// includes
#include <cstdlib>
#include "option.h"
#include "protocol.h"
#include "util.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[] = {
{ "Hash", true, "128", "spin", "min 4 max 1024", NULL },
// JAS
// search X seconds for the best move, equal to "go movetime"
{ "Search Time", true, "0", "spin", "min 0 max 3600", NULL },
// search X plies deep, equal to "go depth"
{ "Search Depth", true, "0", "spin", "min 0 max 20", NULL },
// JAS end
{ "Ponder", true, "false", "check", "", NULL },
{ "OwnBook", true, "true", "check", "", NULL },
{ "BookFile", true, "performance.bin", "string", "", NULL },
{ "Bitbases Path", true, "/usr/share/egbb/", "string", "", NULL },
{ "Bitbases Cache Size", true, "16", "spin", "min 16 max 1024", NULL },
{ "MultiPV", true, "1", "spin", "min 1 max 10", NULL },
{ "NullMove Pruning", true, "Always", "combo", "var Always var Fail High var Never", NULL },
{ "NullMove Reduction", true, "3", "spin", "min 1 max 4", NULL },
{ "Verification Search", true, "Always", "combo", "var Always var Endgame var Never", NULL },
{ "Verification Reduction", true, "5", "spin", "min 1 max 6", NULL },
{ "History Pruning", true, "true", "check", "", NULL },
{ "History Threshold", true, "70", "spin", "min 0 max 100", NULL },
{ "Futility Pruning", true, "true", "check", "", NULL },
{ "Futility Margin", true, "100", "spin", "min 0 max 500", NULL },
{ "Extended Futility Margin", true, "200", "spin", "min 0 max 900", NULL },
{ "Delta Pruning", true, "true", "check", "", NULL },
{ "Delta Margin", true, "50", "spin", "min 0 max 500", NULL },
{ "Quiescence Check Plies", true, "1", "spin", "min 0 max 2", NULL },
{ "Material", true, "100", "spin", "min 0 max 400", NULL },
{ "Piece Activity", true, "100", "spin", "min 0 max 400", NULL },
{ "Piece Square Activity", true, "100", "spin", "min 0 max 400", NULL },
{ "King Safety", true, "100", "spin", "min 0 max 400", NULL },
{ "Pawn Structure", true, "100", "spin", "min 0 max 400", NULL },
{ "Passed Pawns", true, "100", "spin", "min 0 max 400", NULL },
{ "Toga Lazy Eval", true, "true", "check", "", NULL },
{ "Toga Lazy Eval Margin", true, "200", "spin", "min 0 max 900", NULL },
{ "Toga Lazy Eval Mobility Margin", true, "125", "spin", "min 0 max 900", NULL },
{ "Toga Exchange Bonus", false, "20", "spin", "min 0 max 100", NULL },
//{ "Toga King Safety", true, "false", "check", "", NULL },
//{ "Toga King Safety Margin", true, "1700", "spin", "min 500 max 3000", NULL },
//{ "Toga Extended History Pruning",true, "false", "check", "", NULL },
//{ "Toga History Threshold", false, "40", "spin", "min 0 max 100", NULL },
{ "Toga King Pawn Endgame Bonus", true, "30", "spin", "min 0 max 100", NULL },
{ "Toga Rook Pawn Endgame Penalty", true, "10", "spin", "min 0 max 100", NULL },
{ "Number of 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;
ASSERT(var!=NULL);
ASSERT(val!=NULL);
opt = option_find(var);
if (opt == NULL) return false;
my_string_set(&opt->val,val);
return true;
}
// option_get()
const char * option_get(const char var[]) {
option_t * opt;
ASSERT(var!=NULL);
opt = option_find(var);
if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",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 (my_string_equal(val,"true") || my_string_equal(val,"yes") || my_string_equal(val,"1")) {
return true;
} else if (my_string_equal(val,"false") || my_string_equal(val,"no") || my_string_equal(val,"0")) {
return false;
}
ASSERT(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;
ASSERT(var!=NULL);
for (opt = &Option[0]; opt->var != NULL; opt++) {
if (my_string_equal(opt->var,var)) return opt;
}
return NULL;
}
// end of option.cpp
|