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

Converts neural network WDL outputs to centipawns. More...

#include <algorithm>
#include <cmath>
Include dependency graph for WDLConverter.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  WDLConverter
 Handles conversion between Win-Draw-Loss probabilities and centipawn scores. More...
struct  WDLConverter::WDL
 Holds Win, Draw, and Loss probabilities. More...

Detailed Description

Converts neural network WDL outputs to centipawns.

IMPORTANT: This is the INVERSE of WDLNormalizer.hpp's handle_centipawns(). The training formula uses a 0.3 factor that must be accounted for.

Training (WDLNormalizer.hpp): win_rate = sigmoid(cp / SCALE) if cp > 0: w = win_rate, l = (1-w) * 0.3, d = 1 - w - l else: l = 1 - win_rate, w = win_rate * 0.3, d = 1 - l - w

Inverse derivation (this file): We observe that w/(l+w) gives us the key ratio needed to invert. win_ratio = w / (w + l) cp = SCALE * ln(win_ratio / (1 - win_ratio))

Features:

  • Correct inversion of the 0.3 scaling factor
  • Aggression parameter for playstyle tuning (-1.0 to +1.0)