mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 19:46:55 +08:00
Base WDL model on material count and normalize evals dynamically
This PR proposes to change the parameter dependence of Stockfish's internal WDL model from full move counter to material count. In addition it ensures that an evaluation of 100 centipawns always corresponds to a 50% win probability at fishtest LTC, whereas for master this holds only at move number 32. See also https://github.com/official-stockfish/Stockfish/pull/4920 and the discussion therein. The new model was fitted based on about 340M positions extracted from 5.6M fishtest LTC games from the last three weeks, involving SF versions frome67cc979fd(SF 16.1) to current master. The involved commands are for [WDL_model](https://github.com/official-stockfish/WDL_model) are: ``` ./updateWDL.sh --firstreve67cc979fdpython scoreWDL.py updateWDL.json --plot save --pgnName update_material.png --momType "material" --momTarget 58 --materialMin 10 --modelFitting optimizeProbability ``` The anchor `58` for the material count value was chosen to be as close as possible to the observed average material count of fishtest LTC games at move 32 (`43`), while not changing the value of `NormalizeToPawnValue` compared to the move-based WDL model by more than 1. The patch only affects the displayed cp and wdl values. closes https://github.com/official-stockfish/Stockfish/pull/5121 No functional change
This commit is contained in:
committed by
Disservin
parent
117e08c264
commit
9b92ada935
@@ -54,11 +54,11 @@ void hint_common_parent_position(const Position& pos, const Networks& networks)
|
||||
namespace {
|
||||
// Converts a Value into (centi)pawns and writes it in a buffer.
|
||||
// The buffer must have capacity for at least 5 chars.
|
||||
void format_cp_compact(Value v, char* buffer) {
|
||||
void format_cp_compact(Value v, char* buffer, const Position& pos) {
|
||||
|
||||
buffer[0] = (v < 0 ? '-' : v > 0 ? '+' : ' ');
|
||||
|
||||
int cp = std::abs(UCI::to_cp(v));
|
||||
int cp = std::abs(UCI::to_cp(v, pos));
|
||||
if (cp >= 10000)
|
||||
{
|
||||
buffer[1] = '0' + cp / 10000;
|
||||
@@ -90,9 +90,9 @@ void format_cp_compact(Value v, char* buffer) {
|
||||
|
||||
|
||||
// Converts a Value into pawns, always keeping two decimals
|
||||
void format_cp_aligned_dot(Value v, std::stringstream& stream) {
|
||||
void format_cp_aligned_dot(Value v, std::stringstream& stream, const Position& pos) {
|
||||
|
||||
const double pawns = std::abs(0.01 * UCI::to_cp(v));
|
||||
const double pawns = std::abs(0.01 * UCI::to_cp(v, pos));
|
||||
|
||||
stream << (v < 0 ? '-'
|
||||
: v > 0 ? '+'
|
||||
@@ -114,7 +114,7 @@ std::string trace(Position& pos, const Eval::NNUE::Networks& networks) {
|
||||
board[row][8 * 8 + 1] = '\0';
|
||||
|
||||
// A lambda to output one box of the board
|
||||
auto writeSquare = [&board](File file, Rank rank, Piece pc, Value value) {
|
||||
auto writeSquare = [&board, &pos](File file, Rank rank, Piece pc, Value value) {
|
||||
const int x = int(file) * 8;
|
||||
const int y = (7 - int(rank)) * 3;
|
||||
for (int i = 1; i < 8; ++i)
|
||||
@@ -125,7 +125,7 @@ std::string trace(Position& pos, const Eval::NNUE::Networks& networks) {
|
||||
if (pc != NO_PIECE)
|
||||
board[y + 1][x + 4] = PieceToChar[pc];
|
||||
if (value != VALUE_NONE)
|
||||
format_cp_compact(value, &board[y + 2][x + 2]);
|
||||
format_cp_compact(value, &board[y + 2][x + 2], pos);
|
||||
};
|
||||
|
||||
// We estimate the value of each piece by doing a differential evaluation from
|
||||
@@ -180,13 +180,13 @@ std::string trace(Position& pos, const Eval::NNUE::Networks& networks) {
|
||||
{
|
||||
ss << "| " << bucket << " ";
|
||||
ss << " | ";
|
||||
format_cp_aligned_dot(t.psqt[bucket], ss);
|
||||
format_cp_aligned_dot(t.psqt[bucket], ss, pos);
|
||||
ss << " "
|
||||
<< " | ";
|
||||
format_cp_aligned_dot(t.positional[bucket], ss);
|
||||
format_cp_aligned_dot(t.positional[bucket], ss, pos);
|
||||
ss << " "
|
||||
<< " | ";
|
||||
format_cp_aligned_dot(t.psqt[bucket] + t.positional[bucket], ss);
|
||||
format_cp_aligned_dot(t.psqt[bucket] + t.positional[bucket], ss, pos);
|
||||
ss << " "
|
||||
<< " |";
|
||||
if (bucket == t.correctBucket)
|
||||
|
||||
Reference in New Issue
Block a user