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

Files

file  ContinuationHistory.hpp
file  HistoryGravity.hpp
file  HistoryTable.hpp
file  KillerMoves.hpp
file  PawnTable.hpp
file  SearchStack.hpp
file  TranspositionTable.hpp

Classes

struct  ben_bot::ContinuationHistory
struct  ben_bot::HistoryTable
struct  ben_bot::KillerMoves
struct  ben_bot::PawnEntry
class  ben_bot::PawnTable
struct  ben_bot::SearchStack
struct  ben_bot::SearchStackEntry
class  ben_bot::TranspositionTable
struct  ben_bot::TTData

Enumerations

enum class  ben_bot::EvalType : std::uint_least8_t { ben_bot::EvalType::Exact , ben_bot::EvalType::Alpha , ben_bot::EvalType::Beta }

Functions

template<std::integral Entry>
void ben_bot::apply_history_gravity (Entry &entry, const int bonus, const int maxScore) noexcept
auto is_improving (const SearchStackEntry *const entry) noexcept -> bool

Detailed Description

Data structures used by BenBot's search algorithm.

Enumeration Type Documentation

◆ EvalType

enum class ben_bot::EvalType : std::uint_least8_t
strong

This enumeration defines types of evaluation values that different nodes in the search tree may be assigned.

Enumerator
Exact 

Indicates that the evaluation value is an exact evaluation. This also indicates that this is a PV node.

Alpha 

Indicates that the evaluation value is a maximum evaluation; for example, if eval is 16, this means that the evaluation of this node was at most 16.

Beta 

Indicates that the evaluation is a minimum evaluation; for example, if eval is 16, this means that the evaluation of this node was at least 16.

Definition at line 55 of file TranspositionTable.hpp.

Function Documentation

◆ apply_history_gravity()

template<std::integral Entry>
void ben_bot::apply_history_gravity ( Entry & entry,
const int bonus,
const int maxScore )
noexcept

Applies a bonus (or penalty, if negative) to a history heuristic score.

This uses the "history gravity" formula: the bonus is first clamped to [-maxScore, maxScore], and then it's scaled down the closer the score already is to the limit in the bonus's direction. So a score that starts within [-maxScore, maxScore] always stays within it.

The maths is done in int and then narrowed, so this can be used with smaller entry types too, as long as they can hold maxScore.

Definition at line 44 of file HistoryGravity.hpp.

◆ is_improving()

auto is_improving ( const SearchStackEntry *const entry) -> bool
related

Returns true if the given node's static eval is better than it was at the same side's previous turn, i.e. the node 2 plies earlier on the search path.

  • If this node has no static eval (because it's in check), it's never improving.
  • If the node 2 plies earlier has no static eval (it was in check, or it's a sentinel before the root), this compares with the node 4 plies earlier instead.
  • If neither of those has a static eval, there's nothing to compare with, and this returns true. That makes pruning that depends on this flag more cautious when we know the least.

The comparison is strict, so a node whose eval hasn't changed isn't improving.

The entry must be in a SearchStack at or after the root, so that the 4 entries before it are valid (they may be sentinels).

Definition at line 118 of file SearchStack.hpp.