io-chess
UCI chess engine
Loading...
Searching...
No Matches
WDLConverter Class Reference

Handles conversion between Win-Draw-Loss probabilities and centipawn scores. More...

#include <WDLConverter.hpp>

Classes

struct  WDL
 Holds Win, Draw, and Loss probabilities. More...

Public Member Functions

int convert (float win, float draw, float loss) const

Public Attributes

float aggression = 0.0f

Static Public Attributes

static constexpr int MAX_CP = 15000
static constexpr float WDL_SCALE = 1.0f / 0.00368208f

Private Member Functions

int convertWDL (float win, float draw, float loss) const

Detailed Description

Handles conversion between Win-Draw-Loss probabilities and centipawn scores.

Member Function Documentation

◆ convert()

int WDLConverter::convert ( float win,
float draw,
float loss ) const
inline

Convert WDL to centipawn evaluation.

Parameters
winWin probability [0, 1]
drawDraw probability [0, 1]
lossLoss probability [0, 1]
Returns
Centipawn score (positive = STM is winning)
Here is the call graph for this function:

◆ convertWDL()

int WDLConverter::convertWDL ( float win,
float draw,
float loss ) const
inlineprivate

Convert WDL to centipawns - CORRECT INVERSE of WDLNormalizer.

The key insight is that the 0.3 factor creates a ratio that we can invert. From training: if cp > 0: w = sigmoid(cp/S), l = (1-w)*0.3 → w/(w+l) = w/(w + 0.3*(1-w)) = w/(0.3 + 0.7*w) if cp < 0: l = 1-sigmoid(cp/S), w = sigmoid(cp/S)*0.3 → w/(w+l) = 0.3*sig / (0.3*sig + 1-sig) = sig (after solving)

Actually, the simplest correct inverse: win_ratio = w / (w + l) – this extracts the sigmoid! sigmoid(x) = 1 / (1 + exp(-x)) x = ln(win_ratio / (1 - win_ratio)) cp = SCALE * ln(win_ratio / (1 - win_ratio))

Aggression adjusts draw distribution before computing ratio.

Here is the caller graph for this function:

Member Data Documentation

◆ aggression

float WDLConverter::aggression = 0.0f

◆ MAX_CP

int WDLConverter::MAX_CP = 15000
staticconstexpr

◆ WDL_SCALE

float WDLConverter::WDL_SCALE = 1.0f / 0.00368208f
staticconstexpr

The documentation for this class was generated from the following file: