// If running in analysis mode, make sure we use symmetrical king safety. We do this
// by replacing both Weights[kingDangerUs] and Weights[kingDangerThem] by their average.
- if (Options["UCI_AnalyseMode"].value<bool>())
+ if (Options["UCI_AnalyseMode"])
Weights[kingDangerUs] = Weights[kingDangerThem] = (Weights[kingDangerUs] + Weights[kingDangerThem]) / 2;
init_safety();
Score weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight) {
// Scale option value from 100 to 256
- int mg = Options[mgOpt].value<int>() * 256 / 100;
- int eg = Options[egOpt].value<int>() * 256 / 100;
+ int mg = Options[mgOpt] * 256 / 100;
+ int eg = Options[egOpt] * 256 / 100;
return apply_weight(make_score(mg, eg), internalWeight);
}
|| count(SearchMoves.begin(), SearchMoves.end(), ml.move()))
RootMoves.push_back(RootMove(ml.move()));
- if (Options["OwnBook"].value<bool>())
+ if (Options["OwnBook"])
{
- if (Options["Book File"].value<string>() != book.name())
- book.open(Options["Book File"].value<string>());
+ if (book.name() != (string)Options["Book File"])
+ book.open(Options["Book File"]);
- Move bookMove = book.probe(pos, Options["Best Book Move"].value<bool>());
+ Move bookMove = book.probe(pos, Options["Best Book Move"]);
if ( bookMove != MOVE_NONE
&& count(RootMoves.begin(), RootMoves.end(), bookMove))
read_evaluation_uci_options(pos.side_to_move());
Threads.read_uci_options();
- TT.set_size(Options["Hash"].value<int>());
- if (Options["Clear Hash"].value<bool>())
+ TT.set_size(Options["Hash"]);
+ if (Options["Clear Hash"])
{
Options["Clear Hash"] = false;
TT.clear();
}
- UCIMultiPV = Options["MultiPV"].value<size_t>();
- SkillLevel = Options["Skill Level"].value<int>();
+ UCIMultiPV = Options["MultiPV"];
+ SkillLevel = Options["Skill Level"];
// Do we have to play with skill handicap? In this case enable MultiPV that
// we will use behind the scenes to retrieve a set of possible moves.
SkillLevelEnabled = (SkillLevel < 20);
MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, (size_t)4) : UCIMultiPV);
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
{
- Log log(Options["Search Log Filename"].value<string>());
+ Log log(Options["Search Log Filename"]);
log << "\nSearching: " << pos.to_fen()
<< "\ninfinite: " << Limits.infinite
<< " ponder: " << Limits.ponder
Threads.set_timer(0);
Threads.set_size(1);
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
{
int e = elapsed_time();
- Log log(Options["Search Log Filename"].value<string>());
+ Log log(Options["Search Log Filename"]);
log << "Nodes: " << pos.nodes_searched()
<< "\nNodes/second: " << (e > 0 ? pos.nodes_searched() * 1000 / e : 0)
<< "\nBest move: " << move_to_san(pos, RootMoves[0].pv[0]);
if (SkillLevelEnabled && depth == 1 + SkillLevel)
skillBest = do_skill_level();
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
pv_info_to_log(pos, depth, bestValue, elapsed_time(), &RootMoves[0].pv[0]);
// Filter out startup noise when monitoring best move stability
while (m != pv)
pos.undo_move(*--m);
- Log l(Options["Search Log Filename"].value<string>());
+ Log l(Options["Search Log Filename"]);
l << s.str() << endl;
}
void ThreadsManager::read_uci_options() {
- maxThreadsPerSplitPoint = Options["Max Threads per Split Point"].value<int>();
- minimumSplitDepth = Options["Min Split Depth"].value<int>() * ONE_PLY;
- useSleepingThreads = Options["Use Sleeping Threads"].value<bool>();
+ maxThreadsPerSplitPoint = Options["Max Threads per Split Point"];
+ minimumSplitDepth = Options["Min Split Depth"] * ONE_PLY;
+ useSleepingThreads = Options["Use Sleeping Threads"];
- set_size(Options["Threads"].value<int>());
+ set_size(Options["Threads"]);
}
int hypMTG, hypMyTime, t1, t2;
// Read uci parameters
- int emergencyMoveHorizon = Options["Emergency Move Horizon"].value<int>();
- int emergencyBaseTime = Options["Emergency Base Time"].value<int>();
- int emergencyMoveTime = Options["Emergency Move Time"].value<int>();
- int minThinkingTime = Options["Minimum Thinking Time"].value<int>();
+ int emergencyMoveHorizon = Options["Emergency Move Horizon"];
+ int emergencyBaseTime = Options["Emergency Base Time"];
+ int emergencyMoveTime = Options["Emergency Move Time"];
+ int minThinkingTime = Options["Minimum Thinking Time"];
// Initialize to maximum values but unstablePVExtraTime that is reset
unstablePVExtraTime = 0;
maximumSearchTime = std::min(maximumSearchTime, t2);
}
- if (Options["Ponder"].value<bool>())
+ if (Options["Ponder"])
optimumSearchTime += optimumSearchTime / 4;
// Make sure that maxSearchTime is not over absoluteMaxSearchTime
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)
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;
}
UCIOption(bool v, std::string type = "check");
UCIOption(int v, int min, int max);
- template<typename T> T value() const;
void operator=(const std::string& v);
void operator=(bool v) { *this = std::string(v ? "true" : "false"); }
+ operator int() const {
+ assert(type == "check" || type == "button" || type == "spin");
+ return (type == "spin" ? atoi(currentValue.c_str()) : currentValue == "true");
+ }
+
+ operator std::string() const {
+ assert(type == "string");
+ return currentValue;
+ }
+
private:
friend std::ostream& operator<<(std::ostream&, const OptionsMap&);
};
-/// UCIOption::value() definition and specializations
-template<typename T>
-T UCIOption::value() const {
-
- assert(type == "spin");
- return T(atoi(currentValue.c_str()));
-}
-
-template<>
-inline std::string UCIOption::value<std::string>() const {
-
- assert(type == "string");
- return currentValue;
-}
-
-template<>
-inline bool UCIOption::value<bool>() const {
-
- assert(type == "check" || type == "button");
- return currentValue == "true";
-}
-
-
/// Custom comparator because UCI options should be case insensitive
struct CaseInsensitiveLess {
bool operator() (const std::string&, const std::string&) const;