22 static float normalize(
const std::string& eval_str,
bool is_white_to_move) {
26 if (eval_str.find(
'#') != std::string::npos) {
28 std::string moves_str = eval_str;
29 moves_str.erase(std::remove(moves_str.begin(), moves_str.end(),
'#'), moves_str.end());
31 int moves = std::stoi(moves_str);
33 int sign = (moves > 0) ? 1 : -1;
34 cp_val = sign * (
MATE_SCORE - (2000.0 * std::log(std::abs(moves))));
38 cp_val = std::stod(eval_str);
45 float normalized =
static_cast<float>((2.0 / M_PI) * std::atan(cp_val /
GAMMA));
49 if (!is_white_to_move) {
50 normalized = -normalized;