X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fucioption.cpp;h=006c4c56a59e2e223a4cafa441259e1463fa5f1d;hp=9e992be55c26e7fd50462fb4ac5748393d37862e;hb=fbca16da570756f5220b229845e566bd05aa3ce8;hpb=f0701e2b0f4283ba558e7d8cab8e41cf11a19cdd diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 9e992be5..006c4c56 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -22,6 +22,7 @@ //// Includes //// +#include #include #include #include @@ -37,7 +38,7 @@ //// Variables //// -bool Chess960 = false; +bool Chess960; //// @@ -56,15 +57,18 @@ namespace { struct Option { - std::string defaultValue, currentValue; + std::string name, defaultValue, currentValue; OptionType type; + size_t idx; int minValue, maxValue; ComboValues comboValues; Option(); - Option(const std::string& defaultValue, OptionType = STRING); + Option(const char* defaultValue, OptionType = STRING); Option(bool defaultValue, OptionType = CHECK); Option(int defaultValue, int minValue, int maxValue); + + bool operator<(const Option& o) const { return this->idx < o.idx; } }; typedef std::map Options; @@ -121,7 +125,6 @@ namespace { o["Full Depth Moves (PV nodes)"] = Option(14, 1, 100); o["Full Depth Moves (non-PV nodes)"] = Option(3, 1, 100); o["Threat Depth"] = Option(5, 0, 100); - o["Selective Plies"] = Option(7, 0, 10); o["Futility Pruning (Main Search)"] = Option(true); o["Futility Pruning (Quiescence Search)"] = Option(true); o["Futility Margin (Quiescence Search)"] = Option(50, 0, 1000); @@ -142,6 +145,10 @@ namespace { o["MultiPV"] = Option(1, 1, 500); o["UCI_ShowCurrLine"] = Option(false); o["UCI_Chess960"] = Option(false); + + // Any option should know its name so to be easily printed + for (Options::iterator it = o.begin(); it != o.end(); ++it) + it->second.name = it->first; } /// @@ -159,13 +166,6 @@ namespace { return ss.str(); } - // We want conversion from a bool value to be "true" or "false", - // not "1" or "0", so add a specialization for bool type. - template<> - std::string stringify(const bool& v) { - - return v ? "true" : "false"; - } // get_option_value implements the various get_option_value_ // functions defined later, because only the option value @@ -183,19 +183,6 @@ namespace { return ret; } - // Unfortunatly we need a specialization to convert "false" and "true" - // to proper bool values. The culprit is that we use a non standard way - // to store a bool value in a string, in particular we use "false" and - // "true" instead of "0" and "1" due to how UCI protocol works. - - template<> - bool get_option_value(const std::string& optionName) { - - if (options.find(optionName) == options.end()) - return false; - - return options[optionName].currentValue == "true"; - } } //// @@ -240,27 +227,37 @@ void print_uci_options() { "spin", "combo", "check", "string", "button" }; + // Build up a vector out of the options map and sort it according to idx + // field, that is the chronological insertion order in options map. + std::vector