mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
merge "Provide WDL statistics"
110068808b
https://github.com/official-stockfish/Stockfish/pull/2778
https://github.com/official-stockfish/Stockfish/pull/2788
This commit is contained in:
parent
9c19021808
commit
9ce0ef3ac0
5 changed files with 49 additions and 0 deletions
|
@ -66,6 +66,11 @@ Currently, Stockfish has the following UCI options:
|
||||||
If enabled by UCI_LimitStrength, aim for an engine strength of the given Elo.
|
If enabled by UCI_LimitStrength, aim for an engine strength of the given Elo.
|
||||||
This Elo rating has been calibrated at a time control of 60s+0.6s and anchored to CCRL 40/4.
|
This Elo rating has been calibrated at a time control of 60s+0.6s and anchored to CCRL 40/4.
|
||||||
|
|
||||||
|
* #### UCI_ShowWDL
|
||||||
|
If enabled, show approximate WDL statistics as part of the engine output.
|
||||||
|
These WDL numbers model expected game outcomes for a given evaluation and
|
||||||
|
game ply for engine self-play at fishtest LTC conditions (60+0.6s per game).
|
||||||
|
|
||||||
* #### Move Overhead
|
* #### Move Overhead
|
||||||
Assume a time delay of x ms due to network and GUI overheads. This is useful to
|
Assume a time delay of x ms due to network and GUI overheads. This is useful to
|
||||||
avoid losses on time in those cases.
|
avoid losses on time in those cases.
|
||||||
|
|
|
@ -1841,6 +1841,9 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
||||||
<< " multipv " << i + 1
|
<< " multipv " << i + 1
|
||||||
<< " score " << UCI::value(v);
|
<< " score " << UCI::value(v);
|
||||||
|
|
||||||
|
if (Options["UCI_ShowWDL"])
|
||||||
|
ss << UCI::wdl(v, pos.game_ply());
|
||||||
|
|
||||||
if (!tb && i == pvIdx)
|
if (!tb && i == pvIdx)
|
||||||
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
||||||
|
|
||||||
|
|
39
src/uci.cpp
39
src/uci.cpp
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -221,6 +222,28 @@ namespace {
|
||||||
<< "\nNodes/second : " << 1000 * nodes / elapsed << endl;
|
<< "\nNodes/second : " << 1000 * nodes / elapsed << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The win rate model returns the probability (per mille) of winning given an eval
|
||||||
|
// and a game-ply. The model fits rather accurately the LTC fishtest statistics.
|
||||||
|
int win_rate_model(Value v, int ply) {
|
||||||
|
|
||||||
|
// The model captures only up to 240 plies, so limit input (and rescale)
|
||||||
|
double m = std::min(240, ply) / 64.0;
|
||||||
|
|
||||||
|
// Coefficients of a 3rd order polynomial fit based on fishtest data
|
||||||
|
// for two parameters needed to transform eval to the argument of a
|
||||||
|
// logistic function.
|
||||||
|
double as[] = {-8.24404295, 64.23892342, -95.73056462, 153.86478679};
|
||||||
|
double bs[] = {-3.37154371, 28.44489198, -56.67657741, 72.05858751};
|
||||||
|
double a = (((as[0] * m + as[1]) * m + as[2]) * m) + as[3];
|
||||||
|
double b = (((bs[0] * m + bs[1]) * m + bs[2]) * m) + bs[3];
|
||||||
|
|
||||||
|
// Transform eval to centipawns with limited range
|
||||||
|
double x = Utility::clamp(double(100 * v) / PawnValueEg, -1000.0, 1000.0);
|
||||||
|
|
||||||
|
// Return win rate in per mille (rounded to nearest)
|
||||||
|
return int(0.5 + 1000 / (1 + std::exp((a - x) / b)));
|
||||||
|
}
|
||||||
|
|
||||||
// When you calculate check sum, save it and check the consistency later.
|
// When you calculate check sum, save it and check the consistency later.
|
||||||
uint64_t eval_sum;
|
uint64_t eval_sum;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -437,6 +460,22 @@ string UCI::value(Value v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// UCI::wdl() report WDL statistics given an evaluation and a game ply, based on
|
||||||
|
/// data gathered for fishtest LTC games.
|
||||||
|
|
||||||
|
string UCI::wdl(Value v, int ply) {
|
||||||
|
|
||||||
|
stringstream ss;
|
||||||
|
|
||||||
|
int wdl_w = win_rate_model( v, ply);
|
||||||
|
int wdl_l = win_rate_model(-v, ply);
|
||||||
|
int wdl_d = 1000 - wdl_w - wdl_l;
|
||||||
|
ss << " wdl " << wdl_w << " " << wdl_d << " " << wdl_l;
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// UCI::square() converts a Square to a string in algebraic notation (g1, a7, etc.)
|
/// UCI::square() converts a Square to a string in algebraic notation (g1, a7, etc.)
|
||||||
|
|
||||||
std::string UCI::square(Square s) {
|
std::string UCI::square(Square s) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ std::string value(Value v);
|
||||||
std::string square(Square s);
|
std::string square(Square s);
|
||||||
std::string move(Move m, bool chess960);
|
std::string move(Move m, bool chess960);
|
||||||
std::string pv(const Position& pos, Depth depth, Value alpha, Value beta);
|
std::string pv(const Position& pos, Depth depth, Value alpha, Value beta);
|
||||||
|
std::string wdl(Value v, int ply);
|
||||||
Move to_move(const Position& pos, std::string& str);
|
Move to_move(const Position& pos, std::string& str);
|
||||||
|
|
||||||
// Flag that read the evaluation function. This is set to false when evaldir is changed.
|
// Flag that read the evaluation function. This is set to false when evaldir is changed.
|
||||||
|
|
|
@ -75,6 +75,7 @@ void init(OptionsMap& o) {
|
||||||
o["UCI_AnalyseMode"] << Option(false);
|
o["UCI_AnalyseMode"] << Option(false);
|
||||||
o["UCI_LimitStrength"] << Option(false);
|
o["UCI_LimitStrength"] << Option(false);
|
||||||
o["UCI_Elo"] << Option(1350, 1350, 2850);
|
o["UCI_Elo"] << Option(1350, 1350, 2850);
|
||||||
|
o["UCI_ShowWDL"] << Option(false);
|
||||||
o["SyzygyPath"] << Option("<empty>", on_tb_path);
|
o["SyzygyPath"] << Option("<empty>", on_tb_path);
|
||||||
o["SyzygyProbeDepth"] << Option(1, 1, 100);
|
o["SyzygyProbeDepth"] << Option(1, 1, 100);
|
||||||
o["Syzygy50MoveRule"] << Option(true);
|
o["Syzygy50MoveRule"] << Option(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue