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

#include <libbenbot/data-structures/ContinuationHistory.hpp>

Public Member Functions

void age () noexcept
void clear () noexcept
auto get (const bool prevMoverIsWhite, const Move prevMove, const bool moverIsWhite, const Move move) const noexcept -> int
void update (const bool prevMoverIsWhite, const Move prevMove, const bool moverIsWhite, const Move move, const int bonus) noexcept

Static Public Attributes

static constexpr auto MAX_SCORE { 16384 }

Detailed Description

This structure stores continuation history scores for quiet moves.

Each score is indexed by an earlier move on the search path and the current move, each identified by its moving piece (including its color) and its to-square. Because the color is part of the index, the same table can be used for the opponent's last move (1 ply back) and for our own last move (2 plies back), since those are always played by different sides.

Updates work the same way as in the main history table. A null previous move (from a null move, or from the root & the sentinel entries before it in the search stack) has no entry: its score is always 0, and updates through it are ignored.

This table is about 1.1 MiB, so it should be allocated on the heap.

See also
HistoryTable

Definition at line 53 of file ContinuationHistory.hpp.

Member Function Documentation

◆ age()

void ben_bot::ContinuationHistory::age ( )
inlinenoexcept

Halves all the stored scores. Unlike the main history, the search doesn't call this at the start of each search: the table has far more entries, so each one gets few updates, and halving it every move would throw most of them away.

Definition at line 70 of file ContinuationHistory.hpp.

◆ clear()

void ben_bot::ContinuationHistory::clear ( )
inlinenoexcept

Clears all the stored scores.

Definition at line 58 of file ContinuationHistory.hpp.

◆ get()

auto ben_bot::ContinuationHistory::get ( const bool prevMoverIsWhite,
const Move prevMove,
const bool moverIsWhite,
const Move move ) const -> int
inlinenodiscardnoexcept

Returns the score of move when it's played after prevMove. Returns 0 if prevMove is null.

Definition at line 107 of file ContinuationHistory.hpp.

◆ update()

void ben_bot::ContinuationHistory::update ( const bool prevMoverIsWhite,
const Move prevMove,
const bool moverIsWhite,
const Move move,
const int bonus )
inlinenoexcept

Applies a bonus (or penalty, if negative) to the score of move when it's played after prevMove. This does nothing if prevMove is null.

This uses the "history gravity" formula, which keeps scores within [-MAX_SCORE, MAX_SCORE].

Parameters
prevMoverIsWhiteWhether prevMove was played by white.
prevMoveThe earlier move on the search path.
moverIsWhiteWhether move is played by white.
moveThe current move.
bonusThe bonus to apply.

Definition at line 91 of file ContinuationHistory.hpp.

Member Data Documentation

◆ MAX_SCORE

auto ben_bot::ContinuationHistory::MAX_SCORE { 16384 }
staticconstexpr

The maximum absolute value of any score in the table.

Definition at line 55 of file ContinuationHistory.hpp.


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