1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Recreate Position object for eval

takes the current option settings into account.

Fixes #2859
Fixes #2579
This commit is contained in:
Joost VandeVondele 2020-07-31 19:16:38 +02:00
parent 8e28c99f79
commit dbab8b03cf

View file

@ -78,6 +78,17 @@ namespace {
} }
} }
// trace_eval() prints the evaluation for the current position, consistent with the UCI
// options set so far.
void trace_eval(Position& pos) {
StateListPtr states(new std::deque<StateInfo>(1));
Position p;
p.set(pos.fen(), Options["UCI_Chess960"], &states->back(), Threads.main());
sync_cout << "\n" << Eval::trace(p) << sync_endl;
}
// setoption() is called when engine receives the "setoption" UCI command. The // setoption() is called when engine receives the "setoption" UCI command. The
// function updates the UCI option ("name") to the given value ("value"). // function updates the UCI option ("name") to the given value ("value").
@ -166,7 +177,7 @@ namespace {
nodes += Threads.nodes_searched(); nodes += Threads.nodes_searched();
} }
else else
sync_cout << "\n" << Eval::trace(pos) << sync_endl; trace_eval(pos);
} }
else if (token == "setoption") setoption(is); else if (token == "setoption") setoption(is);
else if (token == "position") position(pos, is, states); else if (token == "position") position(pos, is, states);
@ -288,7 +299,7 @@ void UCI::loop(int argc, char* argv[]) {
else if (token == "flip") pos.flip(); else if (token == "flip") pos.flip();
else if (token == "bench") bench(pos, is, states); else if (token == "bench") bench(pos, is, states);
else if (token == "d") sync_cout << pos << sync_endl; else if (token == "d") sync_cout << pos << sync_endl;
else if (token == "eval") sync_cout << Eval::trace(pos) << sync_endl; else if (token == "eval") trace_eval(pos);
else if (token == "compiler") sync_cout << compiler_info() << sync_endl; else if (token == "compiler") sync_cout << compiler_info() << sync_endl;
else else
sync_cout << "Unknown command: " << cmd << sync_endl; sync_cout << "Unknown command: " << cmd << sync_endl;