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

Classical, non-neural evaluation context. More...

#include <SimpleEvalContext.h>

Inheritance diagram for SimpleEvalContext:
Collaboration diagram for SimpleEvalContext:

Public Types

using Score = EvalScore

Public Member Functions

Score evalOneSide (const Board &board, Color us, int &phase) const
 Evaluates features specific to one side.
void evalPawns (const Board &board, Color us, const Bitboard &ourPawns, const Bitboard &theirPawns, Score &score) const
 Evaluates pawn structure features.
void evalKingSafety (const Board &board, Color us, const Bitboard &ourPawns, const Bitboard &theirPawns, Score &score) const
 Evaluates king safety and pawn shield quality.
 SimpleEvalContext ()=default
float evaluate (const Board &board, int ply=0) override
 Computes the tapered static evaluation of the board.
Public Member Functions inherited from IEvaluator
virtual ~IEvaluator ()=default
virtual WDLConverter::WDL evaluateWDL (const Board &board, int ply=0)
 Evaluates the board and returns Win/Draw/Loss probabilities.
virtual float evaluate (const ChessInput &input)
 Evaluates the position using pre-computed features.
virtual void setAggression (float aggression)
 Sets the contempt or aggression factor for the evaluator.
virtual void setEvalScale (int base, int weight)
 Sets the scaling parameters for the evaluation score.
virtual void setEvalNormalization (bool enable)
 Enables or disables dynamic evaluation normalization.
virtual void setIncrementalRebuildInterval (int interval)
 Sets the interval for forcing full feature rebuilds (to correct accumulation errors).
virtual uint64_t getFullRebuilds () const
 Retrieves the number of full feature rebuilds performed (for profiling).

Static Public Member Functions

static int mirror (int sq)
 Mirrors a square index vertically (for black's perspective).

Static Public Attributes

static constexpr int PHASE_KNIGHT = 1
static constexpr int PHASE_BISHOP = 1
static constexpr int PHASE_ROOK = 2
static constexpr int PHASE_QUEEN = 4
static constexpr int TOTAL_PHASE = 24
static constexpr int TEMPO_BONUS = 15
static const Score PIECE_VALUES [6]
static const Score PSQT [6][64]
static constexpr Score BISHOP_PAIR = {30, 80}
static constexpr Score ROOK_OPEN_FILE = {35, 15}
static constexpr Score ROOK_SEMI_OPEN = {15, 10}
static constexpr Score PAWN_PASSED [8]
static constexpr Score PAWN_ISOLATED = {-10, -15}
static constexpr Score PAWN_DOUBLED = {-15, -20}

Detailed Description

Classical, non-neural evaluation context.

Implements a traditional evaluation function based on material, PSQT, pawn structure, mobility, and king safety. Useful as a fallback when the neural network is unavailable.

Member Typedef Documentation

◆ Score

Constructor & Destructor Documentation

◆ SimpleEvalContext()

SimpleEvalContext::SimpleEvalContext ( )
default

Member Function Documentation

◆ evalKingSafety()

void SimpleEvalContext::evalKingSafety ( const Board & board,
Color us,
const Bitboard & ourPawns,
const Bitboard & theirPawns,
Score & score ) const

Evaluates king safety and pawn shield quality.

Here is the call graph for this function:

◆ evalOneSide()

Score SimpleEvalContext::evalOneSide ( const Board & board,
Color us,
int & phase ) const

Evaluates features specific to one side.

Here is the call graph for this function:

◆ evalPawns()

void SimpleEvalContext::evalPawns ( const Board & board,
Color us,
const Bitboard & ourPawns,
const Bitboard & theirPawns,
Score & score ) const

Evaluates pawn structure features.

Here is the call graph for this function:

◆ evaluate()

float SimpleEvalContext::evaluate ( const Board & board,
int ply = 0 )
overridevirtual

Computes the tapered static evaluation of the board.

Parameters
boardThe chess board position.
plyDistance from the search root.
Returns
A scalar score from the perspective of the side to move.

Implements IEvaluator.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mirror()

int SimpleEvalContext::mirror ( int sq)
inlinestatic

Mirrors a square index vertically (for black's perspective).

Here is the caller graph for this function:

Member Data Documentation

◆ BISHOP_PAIR

Score SimpleEvalContext::BISHOP_PAIR = {30, 80}
staticconstexpr

◆ PAWN_DOUBLED

Score SimpleEvalContext::PAWN_DOUBLED = {-15, -20}
staticconstexpr

◆ PAWN_ISOLATED

Score SimpleEvalContext::PAWN_ISOLATED = {-10, -15}
staticconstexpr

◆ PAWN_PASSED

Score SimpleEvalContext::PAWN_PASSED[8]
staticconstexpr
Initial value:
= {{0, 0}, {10, 10}, {10, 20},
{20, 40}, {40, 80}, {80, 160},
{150, 250}, {0, 0}}

◆ PHASE_BISHOP

int SimpleEvalContext::PHASE_BISHOP = 1
staticconstexpr

◆ PHASE_KNIGHT

int SimpleEvalContext::PHASE_KNIGHT = 1
staticconstexpr

◆ PHASE_QUEEN

int SimpleEvalContext::PHASE_QUEEN = 4
staticconstexpr

◆ PHASE_ROOK

int SimpleEvalContext::PHASE_ROOK = 2
staticconstexpr

◆ PIECE_VALUES

const SimpleEvalContext::Score SimpleEvalContext::PIECE_VALUES
static
Initial value:
= {
{100, 120},
{320, 310},
{330, 320},
{500, 525},
{975, 950},
{0, 0}
}

◆ PSQT

const SimpleEvalContext::Score SimpleEvalContext::PSQT
static

◆ ROOK_OPEN_FILE

Score SimpleEvalContext::ROOK_OPEN_FILE = {35, 15}
staticconstexpr

◆ ROOK_SEMI_OPEN

Score SimpleEvalContext::ROOK_SEMI_OPEN = {15, 10}
staticconstexpr

◆ TEMPO_BONUS

int SimpleEvalContext::TEMPO_BONUS = 15
staticconstexpr

◆ TOTAL_PHASE

int SimpleEvalContext::TOTAL_PHASE = 24
staticconstexpr

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