Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::adversarial_search_detail Namespace Reference

Classes

struct  Dummy_State_Key
 
struct  History_Table_Selector
 
struct  History_Table_Selector< Domain, true >
 
struct  NodeEvaluation
 
struct  Null_Transposition_Table
 

Functions

template<AdversarialScore Score>
constexpr Score score_floor () noexcept
 
template<AdversarialScore Score>
constexpr Score score_ceiling () noexcept
 
template<typename Result >
void mark_limit_reached (Result &result)
 
template<SearchMove Move>
SearchPath< Move > prepend_move (const Move &move, const SearchPath< Move > &tail)
 
template<typename Domain , typename Result >
auto evaluate_leaf (Domain &domain, const typename Domain::State &state, Result &result)
 
constexpr size_t remaining_depth (const SearchLimits &limits, const size_t depth) noexcept
 
void accumulate_move_ordering_stats (MoveOrderingStats &dst, const MoveOrderingStats &src) noexcept
 
void accumulate_transposition_stats (TranspositionStats &dst, const TranspositionStats &src) noexcept
 
void accumulate_search_stats (SearchStats &dst, const SearchStats &src) noexcept
 
void accumulate_adversarial_stats (AdversarialSearchStats &dst, const AdversarialSearchStats &src) noexcept
 
template<SearchMove Move, AdversarialScore Score, typename Tracer >
requires AdversarialSearchTracer<Tracer, Move, Score>
void emit_trace (Tracer &tracer, const AdversarialTraceEventKind kind, const size_t depth, const size_t remaining, const size_t iteration=0, const size_t horizon=0, const size_t aspiration_retries=0, const Score value=Score{}, const Score alpha=Score{}, const Score beta=Score{}, const std::optional< Move > &move=std::nullopt, const SearchPath< Move > *principal_variation=nullptr)
 
template<SearchMove Move>
std::optional< Move > first_move_of (const SearchPath< Move > &path)
 
template<AdversarialScore Score>
constexpr Score saturating_subtract (const Score value, const Score delta) noexcept
 
template<AdversarialScore Score>
constexpr Score saturating_add (const Score value, const Score delta) noexcept
 
template<AdversarialScore Score>
constexpr Score grow_aspiration_half_window (const Score current, const AspirationWindow< Score > &window) noexcept
 
template<SearchMove Move, AdversarialScore Score, typename State , typename Table , typename Keyer , typename Result >
void store_adversarial_transposition (State &state, const size_t remaining, Result &result, Table &table, Keyer &keyer, const NodeEvaluation< Move, Score > &value, const TranspositionBound bound, const bool stop)
 Build an adversarial transposition-table entry and store it.
 
template<SearchMove Move, AdversarialScore Score, typename State , typename Table , typename Keyer , typename Result >
AdversarialTranspositionEntry< Move, Score > * probe_and_count_transposition (State &state, const size_t remaining, Result &result, Table &table, Keyer &keyer)
 Probe a transposition table and update probe/hit/miss statistics.
 
template<SearchMove Move, AdversarialScore Score, typename Engine , typename Tracer , typename RunOneIteration >
requires AdversarialSearchTracer<Tracer, Move, Score>
AdversarialIterativeDeepeningResult< Move, Score > run_iterative_deepening (Engine &engine, const ExplorationPolicy &policy, const SearchLimits &limits, const AdversarialIterativeDeepeningOptions< Score > &options, Tracer &tracer, RunOneIteration &&run_one_iteration)
 Core iterative-deepening loop shared by Negamax and Alpha-Beta.
 

Function Documentation

◆ accumulate_adversarial_stats()

void Aleph::adversarial_search_detail::accumulate_adversarial_stats ( AdversarialSearchStats dst,
const AdversarialSearchStats src 
)
inlinenoexcept

◆ accumulate_move_ordering_stats()

void Aleph::adversarial_search_detail::accumulate_move_ordering_stats ( MoveOrderingStats dst,
const MoveOrderingStats src 
)
inlinenoexcept

Definition at line 516 of file Negamax.H.

References Aleph::divide_and_conquer_partition_dp().

Referenced by accumulate_search_stats().

◆ accumulate_search_stats()

void Aleph::adversarial_search_detail::accumulate_search_stats ( SearchStats dst,
const SearchStats src 
)
inlinenoexcept

◆ accumulate_transposition_stats()

void Aleph::adversarial_search_detail::accumulate_transposition_stats ( TranspositionStats dst,
const TranspositionStats src 
)
inlinenoexcept

Definition at line 525 of file Negamax.H.

References Aleph::divide_and_conquer_partition_dp().

Referenced by accumulate_adversarial_stats().

◆ emit_trace()

template<SearchMove Move, AdversarialScore Score, typename Tracer >
requires AdversarialSearchTracer<Tracer, Move, Score>
void Aleph::adversarial_search_detail::emit_trace ( Tracer tracer,
const AdversarialTraceEventKind  kind,
const size_t  depth,
const size_t  remaining,
const size_t  iteration = 0,
const size_t  horizon = 0,
const size_t  aspiration_retries = 0,
const Score  value = Score{},
const Score  alpha = Score{},
const Score  beta = Score{},
const std::optional< Move > &  move = std::nullopt,
const SearchPath< Move > *  principal_variation = nullptr 
)

◆ evaluate_leaf()

template<typename Domain , typename Result >
auto Aleph::adversarial_search_detail::evaluate_leaf ( Domain domain,
const typename Domain::State &  state,
Result &  result 
)

◆ first_move_of()

template<SearchMove Move>
std::optional< Move > Aleph::adversarial_search_detail::first_move_of ( const SearchPath< Move > &  path)

◆ grow_aspiration_half_window()

template<AdversarialScore Score>
constexpr Score Aleph::adversarial_search_detail::grow_aspiration_half_window ( const Score  current,
const AspirationWindow< Score > &  window 
)
constexprnoexcept

Definition at line 626 of file Negamax.H.

References Aleph::divide_and_conquer_partition_dp(), and saturating_add().

◆ mark_limit_reached()

template<typename Result >
void Aleph::adversarial_search_detail::mark_limit_reached ( Result &  result)

Definition at line 470 of file Negamax.H.

References Aleph::LimitReached.

◆ prepend_move()

template<SearchMove Move>
SearchPath< Move > Aleph::adversarial_search_detail::prepend_move ( const Move &  move,
const SearchPath< Move > &  tail 
)

◆ probe_and_count_transposition()

template<SearchMove Move, AdversarialScore Score, typename State , typename Table , typename Keyer , typename Result >
AdversarialTranspositionEntry< Move, Score > * Aleph::adversarial_search_detail::probe_and_count_transposition ( State &  state,
const size_t  remaining,
Result &  result,
Table table,
Keyer keyer 
)

Probe a transposition table and update probe/hit/miss statistics.

Returns a pointer to the stored entry on a cache hit, or nullptr on a miss (or when the table is disabled). The caller is responsible for interpreting the bound field and performing any α-β window narrowing.

Template Parameters
MoveMove type.
ScoreScore type.
StateMutable state type.
TableTransposition-table type (Null or enabled).
KeyerCallable producing a state key.
ResultAdversarial result type.
Parameters
stateMutable state whose key is probed.
remainingSearch depth associated with the probe.
resultAdversarial result object where stats are updated.
tableTransposition table to probe.
keyerCallable that extracts the state key for the table.
Returns
Pointer to the cached entry, or nullptr.

Definition at line 708 of file Negamax.H.

◆ remaining_depth()

constexpr size_t Aleph::adversarial_search_detail::remaining_depth ( const SearchLimits limits,
const size_t  depth 
)
inlineconstexprnoexcept

◆ run_iterative_deepening()

template<SearchMove Move, AdversarialScore Score, typename Engine , typename Tracer , typename RunOneIteration >
requires AdversarialSearchTracer<Tracer, Move, Score>
AdversarialIterativeDeepeningResult< Move, Score > Aleph::adversarial_search_detail::run_iterative_deepening ( Engine engine,
const ExplorationPolicy policy,
const SearchLimits limits,
const AdversarialIterativeDeepeningOptions< Score > &  options,
Tracer tracer,
RunOneIteration &&  run_one_iteration 
)

Core iterative-deepening loop shared by Negamax and Alpha-Beta.

Handles initialization of the result object, the outer depth-stepping loop, per-iteration tracing, stats accumulation, and depth advancement. The engine-specific search call (plain search or aspiration-window search) is delegated to run_one_iteration.

Template Parameters
MoveMove type.
ScoreScore type.
EngineNegamax<Domain> or Alpha_Beta<Domain>.
TracerTrace-event sink.
RunOneIterationCallable (out, iteration, depth, iteration_index) -> void. Responsible for executing one depth-limited search attempt (possibly with aspiration retries) and populating iteration.result and iteration.total_stats.
Parameters
engineInitialized search engine; set_limits is called on it before each iteration.
policyExploration policy stored into the result.
limitsGlobal search limits (must have a finite max_depth).
optionsIterative-deepening options (depth step, initial depth).
tracerTrace sink for Iteration_Begin/Iteration_End events.
run_one_iterationEngine-specific callable for one depth pass.
Returns
Aggregated iterative-deepening result.

Definition at line 761 of file Negamax.H.

References accumulate_adversarial_stats(), Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::aspiration_alpha, Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::aspiration_beta, Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::aspiration_researches, Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::depth, Aleph::divide_and_conquer_partition_dp(), engine, first_move_of(), Aleph::Iteration_Begin, Aleph::Iteration_End, Aleph::SearchLimits::max_depth, options, Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::result, Aleph::AdversarialIterativeDeepeningResult< Move, Score >::result, and Aleph::AdversarialIterativeDeepeningIteration< Move, Score >::total_stats.

◆ saturating_add()

template<AdversarialScore Score>
constexpr Score Aleph::adversarial_search_detail::saturating_add ( const Score  value,
const Score  delta 
)
constexprnoexcept

Definition at line 615 of file Negamax.H.

References Aleph::divide_and_conquer_partition_dp().

Referenced by grow_aspiration_half_window().

◆ saturating_subtract()

template<AdversarialScore Score>
constexpr Score Aleph::adversarial_search_detail::saturating_subtract ( const Score  value,
const Score  delta 
)
constexprnoexcept

Definition at line 604 of file Negamax.H.

References Aleph::divide_and_conquer_partition_dp(), and floor().

◆ score_ceiling()

template<AdversarialScore Score>
constexpr Score Aleph::adversarial_search_detail::score_ceiling ( )
constexprnoexcept

Definition at line 464 of file Negamax.H.

◆ score_floor()

template<AdversarialScore Score>
constexpr Score Aleph::adversarial_search_detail::score_floor ( )
constexprnoexcept

Definition at line 458 of file Negamax.H.

◆ store_adversarial_transposition()

template<SearchMove Move, AdversarialScore Score, typename State , typename Table , typename Keyer , typename Result >
void Aleph::adversarial_search_detail::store_adversarial_transposition ( State &  state,
const size_t  remaining,
Result &  result,
Table table,
Keyer keyer,
const NodeEvaluation< Move, Score > &  value,
const TranspositionBound  bound,
const bool  stop 
)

Build an adversarial transposition-table entry and store it.

Factored out of Negamax and Alpha_Beta to avoid identical member methods. stop corresponds to the engine's internal early-stop flag.

Template Parameters
MoveMove type.
ScoreScore type.
StateMutable state type.
TableTransposition-table type (Null or enabled).
KeyerCallable producing a state key.
ResultAdversarial result type.
Parameters
stateMutable game state whose key is stored.
remainingRemaining search depth for the cached entry.
resultAdversarial result object where stats are updated.
tableTransposition table where the entry is stored.
keyerCallable that extracts the state key for the table.
valueEvaluated node to cache.
boundBound classification for the stored entry.
stopEngine stop flag; no store is performed when true.

Definition at line 656 of file Negamax.H.

References Aleph::AdversarialTranspositionEntry< Move, Score >::bound, Aleph::AdversarialTranspositionEntry< Move, Score >::depth, Aleph::divide_and_conquer_partition_dp(), Aleph::AdversarialTranspositionEntry< Move, Score >::principal_variation, Aleph::adversarial_search_detail::NodeEvaluation< Move, Score >::principal_variation, Aleph::Rejected, Aleph::Replaced, HashStats< HashTbl >::stats(), Aleph::AdversarialTranspositionEntry< Move, Score >::value, and Aleph::adversarial_search_detail::NodeEvaluation< Move, Score >::value.