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

#include <libbenbot/eval/Score.hpp>

Public Types

using LibchessScore = chess::uci::printing::SearchInfo::Score

Public Member Functions

constexpr operator Value () const noexcept
constexpr auto operator- () const noexcept -> Score
auto to_libchess () const noexcept -> LibchessScore
constexpr auto to_tt () const noexcept -> Value
Mate queries
auto is_mate () const noexcept -> bool
constexpr auto is_winning_mate () const noexcept -> bool
constexpr auto is_losing_mate () const noexcept -> bool
auto ply_to_mate () const noexcept -> size_t

Static Public Member Functions

static constexpr auto from_tt (Value eval, size_t plyFromRoot) noexcept -> Score
static constexpr auto mate (const size_t plyFromRoot) noexcept -> Score

Public Attributes

Value value { UINT16_C(0) }

Detailed Description

An evaluation score. This is essentially a wrapper around an integer value, with a few helper methods.

Definition at line 67 of file Score.hpp.

Member Typedef Documentation

◆ LibchessScore

The libchess type used for printing UCI-formatted search information.

Definition at line 111 of file Score.hpp.

Member Function Documentation

◆ from_tt()

auto ben_bot::eval::Score::from_tt ( Value eval,
size_t plyFromRoot ) -> Score
staticnodiscardconstexprnoexcept

Converts a value from the transposition table to a score. This maps the MATE constant to a ply-from-root mate score.

Definition at line 163 of file Score.hpp.

◆ is_losing_mate()

auto ben_bot::eval::Score::is_losing_mate ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true if this score is a losing mate score.

Definition at line 90 of file Score.hpp.

◆ is_mate()

auto ben_bot::eval::Score::is_mate ( ) const -> bool
inlinenodiscardnoexcept

Returns true if this score represents checkmate (either winning or losing).

Definition at line 84 of file Score.hpp.

◆ is_winning_mate()

auto ben_bot::eval::Score::is_winning_mate ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true if this score is a winning mate score.

Definition at line 87 of file Score.hpp.

◆ mate()

constexpr auto ben_bot::eval::Score::mate ( const size_t plyFromRoot) -> Score
inlinestaticnodiscardconstexprnoexcept

Returns a checkmate score. During search, mate scores are based on the distance from the root of the tree, so that the engine actually goes for mate.

Definition at line 120 of file Score.hpp.

◆ operator Value()

ben_bot::eval::Score::operator Value ( ) const
inlineconstexprnoexcept

Implicitly converts this score object to its integer value. This method is intentionally not explicit, which allows score objects to be transparently compared as integers.

Definition at line 75 of file Score.hpp.

◆ operator-()

auto ben_bot::eval::Score::operator- ( ) const -> Score
inlinenodiscardconstexprnoexcept

Inverts the score.

Definition at line 78 of file Score.hpp.

◆ ply_to_mate()

auto ben_bot::eval::Score::ply_to_mate ( ) const -> size_t
inlinenodiscardnoexcept

For a checkmate score, returns the number of plies from the root of the search tree to the checkmate position. This method asserts if the score is not mate.

Definition at line 95 of file Score.hpp.

◆ to_libchess()

auto ben_bot::eval::Score::to_libchess ( ) const -> LibchessScore
inlinenodiscardnoexcept

Converts this score object to the libchess type used for printing UCI info.

Definition at line 176 of file Score.hpp.

◆ to_tt()

auto ben_bot::eval::Score::to_tt ( ) const -> Value
nodiscardconstexprnoexcept

Returns a value suitable for storing in the transposition table. During search, mate scores are based on ply from the root position; this function maps all mate scores to the MATE constant.

Definition at line 152 of file Score.hpp.

Member Data Documentation

◆ value

The evaluation value, in centipawns.

Definition at line 69 of file Score.hpp.


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