31 static constexpr float SCALE = 1.0f / 0.00368208;
34 static constexpr float MATE_CP = 15000.0f;
51 if (eval_str.find(
'#') != std::string::npos) {
57 cp = std::stof(eval_str);
60 return {0.33f, 0.34f, 0.33f};
66 if (!is_white_to_move) {
67 std::swap(result.
win, result.
loss);
82 bool is_white_to_move) {
85 if (eval_str.find(
'#') != std::string::npos) {
87 std::string s = eval_str;
88 s.erase(std::remove(s.begin(), s.end(),
'#'), s.end());
89 int moves = std::stoi(s);
90 int sign = (moves > 0) ? 1 : -1;
92 cp = sign * (
MATE_CP - std::abs(moves) * 10.0f);
95 cp = std::stof(eval_str);
102 if (!is_white_to_move) {
116 float win_rate = 1.0f / (1.0f + std::exp(-cp /
SCALE));
123 l = (1.0f - w) * 0.3f;
133 w = std::max(0.0f, w);
134 d = std::max(0.0f, d);
135 l = std::max(0.0f, l);
136 float sum = w + d + l;
138 return {w / sum, d / sum, l / sum};
146 s.erase(std::remove(s.begin(), s.end(),
'#'), s.end());
147 int moves = std::stoi(s);
151 return {1.0f, 0.0f, 0.0f};
154 return {0.0f, 0.0f, 1.0f};
Definition WDLNormalizer.hpp:27
static constexpr float SCALE
Definition WDLNormalizer.hpp:31
static constexpr float MATE_CP
Definition WDLNormalizer.hpp:34
static WDLOutput handle_centipawns(float cp)
Definition WDLNormalizer.hpp:114
static float to_centipawns(const std::string &eval_str, bool is_white_to_move)
Definition WDLNormalizer.hpp:81
static WDLOutput convert(const std::string &eval_str, bool is_white_to_move)
Definition WDLNormalizer.hpp:47
static WDLOutput handle_mate(std::string s)
Definition WDLNormalizer.hpp:145
Definition WDLNormalizer.hpp:14
float draw
Definition WDLNormalizer.hpp:16
float loss
Definition WDLNormalizer.hpp:17
float win
Definition WDLNormalizer.hpp:15