BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Evaluation
Collaboration diagram for Evaluation:

Files

file  Evaluation.hpp
file  Material.hpp
file  Score.hpp

Namespaces

namespace  ben_bot
namespace  ben_bot::eval
namespace  ben_bot::eval::piece_values

Classes

struct  std::formatter< ben_bot::eval::Score >
struct  ben_bot::eval::Score

Typedefs

using ben_bot::eval::Value = std::int16_t

Functions

auto ben_bot::eval::evaluate (const Position &position) -> Score
constexpr auto ben_bot::eval::piece_values::get (PieceType type) noexcept -> Value
constexpr auto ben_bot::eval::score_material (const Position &position) noexcept -> Value

Variables

constexpr Value ben_bot::eval::DRAW { UINT16_C(0) }
constexpr Value ben_bot::eval::MATE { MAX / UINT16_C(2) }
constexpr Value ben_bot::eval::MAX { std::numeric_limits<Value>::max() - UINT16_C(5) }
constexpr Value ben_bot::eval::piece_values::PAWN { UINT16_C(100) }
constexpr Value ben_bot::eval::piece_values::KNIGHT { UINT16_C(320) }
constexpr Value ben_bot::eval::piece_values::BISHOP { UINT16_C(330) }
constexpr Value ben_bot::eval::piece_values::ROOK { UINT16_C(500) }
constexpr Value ben_bot::eval::piece_values::QUEEN { UINT16_C(900) }
constexpr Value ben_bot::eval::piece_values::KING { UINT16_C(10000) }

Detailed Description

Functions for evaluating positions.

Typedef Documentation

◆ Value

using ben_bot::eval::Value = std::int16_t

Signed integer type used to represent evaluation values.

Definition at line 38 of file Score.hpp.

Function Documentation

◆ evaluate()

auto ben_bot::eval::evaluate ( const Position & position) -> Score
nodiscard

Returns a numerical score representing the evaluation of the give position from the perspective of the side to move. Higher numbers are better for the side to move.

◆ get()

auto ben_bot::eval::piece_values::get ( PieceType type) -> Value
nodiscardconstexprnoexcept

Returns the value of the given piece type.

Definition at line 97 of file Material.hpp.

◆ score_material()

auto ben_bot::eval::score_material ( const Position & position) -> Value
nodiscardconstexprnoexcept

Returns an aggregate score for the material on the board, relative to the side to move.

Definition at line 133 of file Material.hpp.

Variable Documentation

◆ BISHOP

Value ben_bot::eval::piece_values::BISHOP { UINT16_C(330) }
inlineconstexpr

The value of a bishop.

Definition at line 48 of file Material.hpp.

◆ DRAW

Value ben_bot::eval::DRAW { UINT16_C(0) }
inlineconstexpr

A neutral, or draw, score.

Definition at line 59 of file Score.hpp.

◆ KING

Value ben_bot::eval::piece_values::KING { UINT16_C(10000) }
inlineconstexpr

The value of the king. This value isn't really used in counting material, it's just an arbitrarily large placeholder value.

Definition at line 60 of file Material.hpp.

◆ KNIGHT

Value ben_bot::eval::piece_values::KNIGHT { UINT16_C(320) }
inlineconstexpr

The value of a knight

Definition at line 45 of file Material.hpp.

◆ MATE

Value ben_bot::eval::MATE { MAX / UINT16_C(2) }
inlineconstexpr

The maximum possible evaluation score, i.e., if the side to move has mate-in-1. If the side to move is in checkmate, the evaluation is -MATE.

Definition at line 54 of file Score.hpp.

◆ MAX

Value ben_bot::eval::MAX { std::numeric_limits<Value>::max() - UINT16_C(5) }
inlineconstexpr

Arbitrary value used as the starting beta value for alpha/beta search. This should be larger than mate, but smaller than the data type's max (to avoid issues with sign flipping).

Definition at line 46 of file Score.hpp.

◆ PAWN

Value ben_bot::eval::piece_values::PAWN { UINT16_C(100) }
inlineconstexpr

The value of a pawn.

Definition at line 42 of file Material.hpp.

◆ QUEEN

Value ben_bot::eval::piece_values::QUEEN { UINT16_C(900) }
inlineconstexpr

The value of a queen.

Definition at line 54 of file Material.hpp.

◆ ROOK

Value ben_bot::eval::piece_values::ROOK { UINT16_C(500) }
inlineconstexpr

The value of a rook.

Definition at line 51 of file Material.hpp.