BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
ben_bot::eval::CoeffTracer Struct Referencefinal

#include <libbenbot/eval/Trace.hpp>

Collaboration diagram for ben_bot::eval::CoeffTracer:

Public Member Functions

constexpr void add (const Term term, const Color side, const int count, const size_t index=0uz) noexcept
constexpr void add_base (const Color side, const TaperedScore &part) noexcept
constexpr auto coefficient (const size_t index) const noexcept -> int
constexpr auto score (const Weights &weights) const noexcept -> Score
constexpr auto white_score (const Weights &weights) const noexcept -> TaperedScore

Public Attributes

TaperedScore base { }
std::array< std::array< std::int16_t, 2uz >, NUM_WEIGHTS > coeffs { }
std::int32_t phase { MAX_PHASE }
Color sideToMove { Color::White }

Static Public Attributes

static constexpr bool ENABLED = true

Detailed Description

A tracer that records, for each eval weight, how many times it applied for each side.

The eval is then score(DEFAULT_WEIGHTS): the sum of each weight times its White coefficient minus its Black coefficient, plus base, blended by phase and negated if Black is to move. A tuner can call score() with other weights.

See also
evaluate_traced()

Definition at line 112 of file Trace.hpp.

Member Function Documentation

◆ add()

void ben_bot::eval::CoeffTracer::add ( const Term term,
const Color side,
const int count,
const size_t index = 0uz )
inlineconstexprnoexcept

Records that a term applied count times for side.

Definition at line 135 of file Trace.hpp.

◆ add_base()

void ben_bot::eval::CoeffTracer::add_base ( const Color side,
const TaperedScore & part )
inlineconstexprnoexcept

Adds a part of the eval that isn't traced by weight, from side's point of view.

Definition at line 146 of file Trace.hpp.

◆ coefficient()

auto ben_bot::eval::CoeffTracer::coefficient ( const size_t index) const -> int
inlinenodiscardconstexprnoexcept

Returns the White coefficient minus the Black coefficient of the weight at index in Weights::values.

Definition at line 157 of file Trace.hpp.

◆ score()

auto ben_bot::eval::CoeffTracer::score ( const Weights & weights) const -> Score
inlinenodiscardconstexprnoexcept

Rebuilds the eval from the given weights, from the side to move's point of view. With DEFAULT_WEIGHTS, this is exactly what evaluate() returns.

Definition at line 180 of file Trace.hpp.

◆ white_score()

auto ben_bot::eval::CoeffTracer::white_score ( const Weights & weights) const -> TaperedScore
inlinenodiscardconstexprnoexcept

Rebuilds the eval's middlegame & endgame scores from the given weights, from White's point of view.

Definition at line 167 of file Trace.hpp.

Member Data Documentation

◆ base

TaperedScore ben_bot::eval::CoeffTracer::base { }

The parts of the eval that aren't traced by weight, from White's point of view. These are the endgame conversion helpers (the mop-up & last piece terms), which aren't tunable and only apply behind gates on the fixed piece_values.

Definition at line 126 of file Trace.hpp.

◆ coeffs

std::array<std::array<std::int16_t, 2uz>, NUM_WEIGHTS> ben_bot::eval::CoeffTracer::coeffs { }

The number of times each weight applied for each side, indexed by [weight][Color]. The weights are in the order of Weights::values. These can be negative, for terms such as space that count our squares minus theirs.

Definition at line 120 of file Trace.hpp.

◆ ENABLED

bool ben_bot::eval::CoeffTracer::ENABLED = true
staticconstexpr

True if this tracer records anything.

Definition at line 114 of file Trace.hpp.

◆ phase

std::int32_t ben_bot::eval::CoeffTracer::phase { MAX_PHASE }

The game phase used to blend the middlegame & endgame scores, in [0, MAX_PHASE].

Definition at line 129 of file Trace.hpp.

◆ sideToMove

Color ben_bot::eval::CoeffTracer::sideToMove { Color::White }

The side to move. The eval is from this side's point of view.

Definition at line 132 of file Trace.hpp.


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