Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Fix some more UCI output
Browse files Browse the repository at this point in the history
further fall-out of the refactoring, fixes:

* the position object in UCI is not never getting updated if position token is used
* duplicate string of " wdl "

See also:

https://discord.com/channels/435943710472011776/1032922913499783169/1228227522945351690
https://discord.com/channels/435943710472011776/813919248455827515/1228288106449338398

closes official-stockfish#5168

No functional change

Co-Authored-By: disservin <[email protected]>
  • Loading branch information
2 people authored and vondele committed Apr 12, 2024
1 parent e58b3b4 commit 14f6eab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void UCIEngine::loop() {
else if (token == "go")
go(pos, is);
else if (token == "position")
position(is);
position(pos, is);
else if (token == "ucinewgame")
engine.search_clear();
else if (token == "isready")
Expand Down Expand Up @@ -268,7 +268,7 @@ void UCIEngine::bench(Position& pos, std::istream& args) {
else if (token == "setoption")
setoption(is);
else if (token == "position")
position(is);
position(pos, is);
else if (token == "ucinewgame")
{
engine.search_clear(); // search_clear may take a while
Expand All @@ -294,7 +294,7 @@ void UCIEngine::setoption(std::istringstream& is) {
engine.get_options().setoption(is);
}

void UCIEngine::position(std::istringstream& is) {
void UCIEngine::position(Position& pos, std::istringstream& is) {
std::string token, fen;

is >> token;
Expand All @@ -317,6 +317,7 @@ void UCIEngine::position(std::istringstream& is) {
moves.push_back(token);
}

pos.set(fen, engine.get_options()["UCI_Chess960"], pos.state());
engine.set_position(fen, moves);
}

Expand Down Expand Up @@ -393,7 +394,7 @@ std::string UCIEngine::wdl(Value v, const Position& pos) {
int wdl_w = win_rate_model(v, pos);
int wdl_l = win_rate_model(-v, pos);
int wdl_d = 1000 - wdl_w - wdl_l;
ss << " wdl " << wdl_w << " " << wdl_d << " " << wdl_l;
ss << wdl_w << " " << wdl_d << " " << wdl_l;

return ss.str();
}
Expand Down
2 changes: 1 addition & 1 deletion src/uci.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class UCIEngine {

void go(Position& pos, std::istringstream& is);
void bench(Position& pos, std::istream& args);
void position(std::istringstream& is);
void position(Position& pos, std::istringstream& is);
void setoption(std::istringstream& is);

static void on_update_no_moves(const Engine::InfoShort& info);
Expand Down

0 comments on commit 14f6eab

Please sign in to comment.