Skip to content

Commit 887dc73

Browse files
committed
fix: load openings at right time
1 parent 4ed8c16 commit 887dc73

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/opening.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace Opening {
7676
return {"", ""};
7777
}
7878

79-
string sequence = strip(possible[Random::random()%possible.size()]);
79+
string sequence = strip(possible[Random::random() % possible.size()]);
8080

8181
return {sequence, sequence.substr(moves.size(), 5)};
8282
}

src/uci.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ int loop() {
183183
string cmd;
184184
Options options;
185185
Position pos = Bitboard::startpos();
186-
Opening::load_openings(options);
187186
vector<string> move_list = {};
188187
float prev_eval = 0;
189188
bool searching = false;
190189

190+
if (options.OwnBook) {
191+
Opening::load_openings(options);
192+
}
193+
191194
while (getline(cin, cmd)) {
192195
cmd = strip(cmd);
193196

@@ -231,9 +234,14 @@ int loop() {
231234
else if (name == "EvalKings") options.EvalKings = std::stof(value)/100;
232235

233236
else if (name == "OwnBook") {
234-
if (value == "true") options.OwnBook = true;
235-
else if (value == "false") options.OwnBook = false;
236-
else std::cerr << "Unknown value: " << value << endl;
237+
if (value == "true") {
238+
options.OwnBook = true;
239+
Opening::load_openings(options);
240+
} else if (value == "false") {
241+
options.OwnBook = false;
242+
} else {
243+
std::cerr << "Unknown value: " << value << endl;
244+
}
237245
}
238246

239247
else if (name == "OwnBookPath") {

0 commit comments

Comments
 (0)