mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 10:57:43 +00:00
Move options into the engine
Move the engine options into the engine class, also avoid duplicated initializations after startup. UCIEngine needs to register an add_listener to listen to all option changes and print these. Also avoid a double initialization of the TT, which was the case with the old state. closes https://github.com/official-stockfish/Stockfish/pull/5356 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
c8213ba0d0
commit
7013a22b74
+8
-8
@@ -21,6 +21,7 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -33,19 +34,19 @@ namespace Stockfish {
|
||||
bool Tune::update_on_last;
|
||||
const Option* LastOption = nullptr;
|
||||
OptionsMap* Tune::options;
|
||||
|
||||
|
||||
namespace {
|
||||
std::map<std::string, int> TuneResults;
|
||||
|
||||
void on_tune(const Option& o) {
|
||||
std::optional<std::string> on_tune(const Option& o) {
|
||||
|
||||
if (!Tune::update_on_last || LastOption == &o)
|
||||
Tune::read_options();
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void make_option(OptionsMap* options, const string& n, int v, const SetRange& r) {
|
||||
void Tune::make_option(OptionsMap* opts, const string& n, int v, const SetRange& r) {
|
||||
|
||||
// Do not generate option when there is nothing to tune (ie. min = max)
|
||||
if (r(v).first == r(v).second)
|
||||
@@ -54,8 +55,8 @@ void make_option(OptionsMap* options, const string& n, int v, const SetRange& r)
|
||||
if (TuneResults.count(n))
|
||||
v = TuneResults[n];
|
||||
|
||||
(*options)[n] << Option(v, r(v).first, r(v).second, on_tune);
|
||||
LastOption = &((*options)[n]);
|
||||
(*opts)[n] << Option(v, r(v).first, r(v).second, on_tune);
|
||||
LastOption = &((*opts)[n]);
|
||||
|
||||
// Print formatted parameters, ready to be copy-pasted in Fishtest
|
||||
std::cout << n << "," //
|
||||
@@ -65,7 +66,6 @@ void make_option(OptionsMap* options, const string& n, int v, const SetRange& r)
|
||||
<< (r(v).second - r(v).first) / 20.0 << "," //
|
||||
<< "0.0020" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
string Tune::next(string& names, bool pop) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user