Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong sign for 200 TB score #5172

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Score::Score(Value v, const Position& pos) {
else if (std::abs(v) <= VALUE_TB)
{
auto distance = VALUE_TB - std::abs(v);
score = (v > 0) ? TBWin{distance} : TBWin{-distance};
score = (v > 0) ? Tablebase{distance, true} : Tablebase{-distance, false};
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions src/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class Score {
int plies;
};

struct TBWin {
int plies;
struct Tablebase {
int plies;
bool win;
};

struct InternalUnits {
Expand All @@ -61,7 +62,7 @@ class Score {
}

private:
std::variant<Mate, TBWin, InternalUnits> score;
std::variant<Mate, Tablebase, InternalUnits> score;
};

}
Expand Down
6 changes: 3 additions & 3 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ std::string UCIEngine::format_score(const Score& s) {
auto m = (mate.plies > 0 ? (mate.plies + 1) : mate.plies) / 2;
return std::string("mate ") + std::to_string(m);
},
[](Score::TBWin tb) -> std::string {
[](Score::Tablebase tb) -> std::string {
return std::string("cp ")
+ std::to_string((tb.plies > 0 ? TB_CP - tb.plies : -TB_CP - tb.plies));
+ std::to_string((tb.win ? TB_CP - tb.plies : -TB_CP - tb.plies));
},
[](Score::InternalUnits units) -> std::string {
return std::string("cp ") + std::to_string(units.value);
Expand Down Expand Up @@ -435,7 +435,7 @@ Move UCIEngine::to_move(const Position& pos, std::string str) {
}

void UCIEngine::on_update_no_moves(const Engine::InfoShort& info) {
sync_cout << "info depth" << info.depth << " score " << format_score(info.score) << sync_endl;
sync_cout << "info depth " << info.depth << " score " << format_score(info.score) << sync_endl;
}

void UCIEngine::on_update_full(const Engine::InfoFull& info, bool showWDL) {
Expand Down