Add user-defined conversions to UCIOption

Greatly improves the usage. User defined conversions
are a novelity for SF, another amazing C++ facility
at work !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-12-28 18:27:18 +01:00
parent ae65ab25d5
commit 0759d8f430
6 changed files with 44 additions and 54 deletions

View File

@@ -157,7 +157,7 @@ namespace {
else
return;
pos.from_fen(fen, Options["UCI_Chess960"].value<bool>());
pos.from_fen(fen, Options["UCI_Chess960"]);
// Parse move list (if any)
while (is >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
@@ -188,10 +188,14 @@ namespace {
while (is >> token)
value += string(" ", !value.empty()) + token;
if (Options.count(name))
Options[name] = (value.empty() ? "true" : value); // UCI buttons don't have "value"
else
if (!Options.count(name))
cout << "No such option: " << name << endl;
else if (value.empty()) // UCI buttons don't have a value
Options[name] = true;
else
Options[name] = value;
}