|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Pure Negamax search over an implicit game tree. More...
#include <Negamax.H>
Public Types | |
| using | Domain_Type = Domain |
| Type of the problem domain. | |
| using | State = typename Domain::State |
| Concrete search state type. | |
| using | Move = typename Domain::Move |
| Move type. | |
| using | Score = typename Domain::Score |
| Score type used for board evaluation. | |
| using | Result = AdversarialSearchResult< Move, Score > |
| Outcome of an adversarial search execution. | |
Public Member Functions | |
| Negamax (Domain domain, ExplorationPolicy policy=default_policy(), const SearchLimits &limits={}) | |
| Build a Negamax engine bound to one game domain. | |
| const Domain & | domain () const noexcept |
| Read-only access to the bound game domain. | |
| Domain & | domain () noexcept |
| Mutable access to the bound game domain. | |
| const ExplorationPolicy & | policy () const noexcept |
| Current exploration policy. | |
| const SearchLimits & | limits () const noexcept |
| Current hard limits. | |
| void | set_policy (const ExplorationPolicy &policy) noexcept |
| Replace the exploration policy for future runs. | |
| void | set_limits (const SearchLimits &limits) noexcept |
| Replace the hard limits for future runs. | |
| Result | search (State initial_state) |
Execute Negamax from initial_state. | |
| template<typename Tracer > requires AdversarialSearchTracer<Tracer, Move, Score> | |
| Result | search (State initial_state, Tracer &tracer) |
Execute Negamax from initial_state while emitting trace events. | |
| template<typename Table , typename Keyer > requires AdversarialSearchKeyer<Table, Keyer, State, Move, Score> | |
| Result | search (State initial_state, Table &table, Keyer keyer) |
| Execute Negamax with a transposition table and explicit keyer. | |
| template<typename Table , typename Keyer , typename Tracer > requires AdversarialSearchKeyer<Table, Keyer, State, Move, Score> | |
| and AdversarialSearchTracer< Tracer, Move, Score > Result | search (State initial_state, Table &table, Keyer keyer, Tracer &tracer) |
| Execute Negamax with TT/keyer and a trace sink. | |
| template<typename Table , typename D_ = Domain> requires SearchStateKeyProvider<D_> | |
| and AdversarialTranspositionMemo< Table, typename D_::State_Key, Move, Score > Result | search (State initial_state, Table &table) |
Execute Negamax with a transposition table using domain().state_key(). | |
| template<typename Table , typename Tracer , typename D_ = Domain> requires SearchStateKeyProvider<D_> | |
| and AdversarialTranspositionMemo< Table, typename D_::State_Key, Move, Score > and AdversarialSearchTracer< Tracer, Move, Score > Result | search (State initial_state, Table &table, Tracer &tracer) |
| Execute Negamax with domain-provided key and a trace sink. | |
Static Public Member Functions | |
| static ExplorationPolicy | default_policy () noexcept |
| Return the default exploration policy for adversarial search. | |
Static Public Attributes | |
| static constexpr bool | supports_best_first = false |
| Compile-time marker: Negamax only supports Depth_First strategy. | |
Private Attributes | |
| Domain | domain_ |
| ExplorationPolicy | policy_ |
| SearchLimits | limits_ |
| bool | stop_ = false |
Pure Negamax search over an implicit game tree.
Negamax is the canonical base for two-player zero-sum search because a single maximization recurrence is enough once evaluation is defined from the side-to-move perspective.
| Domain | game adapter exposing adversarial-search hooks. |
| using Aleph::Negamax< Domain >::Domain_Type = Domain |
| using Aleph::Negamax< Domain >::Move = typename Domain::Move |
| using Aleph::Negamax< Domain >::Result = AdversarialSearchResult<Move, Score> |
| using Aleph::Negamax< Domain >::Score = typename Domain::Score |
| using Aleph::Negamax< Domain >::State = typename Domain::State |
|
inlineexplicit |
|
inlinestaticnoexcept |
Return the default exploration policy for adversarial search.
Definition at line 862 of file Negamax.H.
References Aleph::ExplorationPolicy::Depth_First, Aleph::Negamax< Domain >::policy(), Aleph::ExplorationPolicy::stop_at_first_solution, and Aleph::ExplorationPolicy::strategy.
Referenced by Aleph::Alpha_Beta< Domain >::default_policy(), and TEST().
|
inlinenoexcept |
Read-only access to the bound game domain.
Definition at line 879 of file Negamax.H.
References Aleph::Negamax< Domain >::domain_.
|
inlinenoexcept |
Mutable access to the bound game domain.
Definition at line 885 of file Negamax.H.
References Aleph::Negamax< Domain >::domain_.
|
inlineprivate |
Definition at line 1034 of file Negamax.H.
References Aleph::search_engine_detail::expansion_limit_reached(), Aleph::Negamax< Domain >::limits_, and Aleph::Negamax< Domain >::stop_.
Referenced by Aleph::Negamax< Domain >::search_node().
|
inlinenoexcept |
Current hard limits.
Definition at line 897 of file Negamax.H.
References Aleph::Negamax< Domain >::limits_.
Referenced by Aleph::Negamax< Domain >::set_limits().
|
inlinenoexcept |
Current exploration policy.
Definition at line 891 of file Negamax.H.
References Aleph::Negamax< Domain >::policy_.
Referenced by Aleph::Negamax< Domain >::default_policy(), and Aleph::Negamax< Domain >::set_policy().
|
inlineprivate |
Definition at line 1059 of file Negamax.H.
References Aleph::and, Aleph::TranspositionStats::cutoffs, Aleph::divide_and_conquer_partition_dp(), Aleph::Exact, Aleph::AdversarialSearchResult< Move, Score >::stats, and Aleph::AdversarialSearchStats::transpositions.
Referenced by Aleph::Negamax< Domain >::search_node().
|
inline |
Execute Negamax from initial_state.
| [in] | initial_state | Root position. Its side to move defines the perspective of the returned score. |
domain().evaluate(state) returns values in [score_floor<Score>(), score_ceiling<Score>()]. The engine keeps std::numeric_limits<Score>::lowest() as an internal sentinel and remaps it to std::numeric_limits<Score>::max() when a negation would otherwise overflow.| std::invalid_argument | if a non-depth-first exploration strategy is requested or common limits are malformed. |
Definition at line 928 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Negamax< Domain >::search().
Referenced by Aleph::Negamax< Domain >::search(), Aleph::Negamax< Domain >::search(), and TEST().
|
inline |
Execute Negamax with a transposition table using domain().state_key().
Definition at line 971 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), Aleph::Negamax< Domain >::domain_, and Aleph::Negamax< Domain >::search_impl().
|
inline |
Execute Negamax with a transposition table and explicit keyer.
keyer(state) must return a stable key that identifies search-equivalent states. The engine internally combines it with remaining depth to keep the cache consistent with the configured horizon.
Definition at line 952 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Negamax< Domain >::search().
|
inline |
Execute Negamax with TT/keyer and a trace sink.
Definition at line 962 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Negamax< Domain >::search_impl().
|
inline |
Execute Negamax with domain-provided key and a trace sink.
Definition at line 987 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), Aleph::Negamax< Domain >::domain_, and Aleph::Negamax< Domain >::search_impl().
|
inline |
Execute Negamax from initial_state while emitting trace events.
Definition at line 937 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Negamax< Domain >::search_impl().
|
inlineprivate |
Definition at line 1005 of file Negamax.H.
References ah_invalid_argument_if, Aleph::ExplorationPolicy::Depth_First, Aleph::divide_and_conquer_partition_dp(), Aleph::Domain, Aleph::SearchStats::elapsed_ms, Aleph::Exhausted, Aleph::AdversarialSearchResult< Move, Score >::limits, Aleph::Negamax< Domain >::limits_, Aleph::SearchLimits::max_solutions, Aleph::ExplorationPolicy::move_ordering, Aleph::NotStarted, Aleph::AdversarialSearchResult< Move, Score >::policy, Aleph::Negamax< Domain >::policy_, Aleph::AdversarialSearchResult< Move, Score >::principal_variation, root(), Aleph::search_elapsed_ms(), Aleph::Negamax< Domain >::search_node(), Aleph::AdversarialSearchResult< Move, Score >::stats, Aleph::AdversarialSearchResult< Move, Score >::status, Aleph::Negamax< Domain >::stop_, Aleph::ExplorationPolicy::strategy, Aleph::ExplorationPolicy::use_history_heuristic, Aleph::ExplorationPolicy::use_killer_moves, and Aleph::AdversarialSearchResult< Move, Score >::value.
Referenced by Aleph::Negamax< Domain >::search(), Aleph::Negamax< Domain >::search(), Aleph::Negamax< Domain >::search(), and Aleph::Negamax< Domain >::search().
|
inlineprivate |
Definition at line 1082 of file Negamax.H.
References Aleph::Depth_Cutoff, Aleph::divide_and_conquer_partition_dp(), Aleph::Negamax< Domain >::domain_, Aleph::Domain_Prune, Aleph::adversarial_search_detail::emit_trace(), Aleph::Enter_Node, Aleph::adversarial_search_detail::evaluate_leaf(), Aleph::Exact, Aleph::Exit_Node, Aleph::SearchStats::expanded_states, Aleph::Expansion_Limit, Aleph::Negamax< Domain >::expansion_limit_reached(), Aleph::adversarial_search_detail::first_move_of(), Aleph::SearchStats::generated_successors, Aleph::Negamax< Domain >::limits_, Aleph::SearchLimits::max_depth, Aleph::adversarial_search_detail::prepend_move(), Aleph::adversarial_search_detail::NodeEvaluation< Move, Score >::principal_variation, Aleph::Negamax< Domain >::probe_transposition(), Aleph::SearchStats::pruned_by_depth, Aleph::SearchStats::pruned_by_domain, Aleph::search_engine_detail::register_visit(), Aleph::adversarial_search_detail::remaining_depth(), Aleph::Negamax< Domain >::search_node(), Aleph::search_engine_detail::should_prune_state(), Aleph::AdversarialSearchResult< Move, Score >::stats, Aleph::Negamax< Domain >::stop_, Aleph::Negamax< Domain >::store_transposition(), Aleph::Terminal_Node, Aleph::SearchStats::terminal_states, Aleph::Transposition_Hit, and Aleph::adversarial_search_detail::NodeEvaluation< Move, Score >::value.
Referenced by Aleph::Negamax< Domain >::search_impl(), and Aleph::Negamax< Domain >::search_node().
|
inlinenoexcept |
Replace the hard limits for future runs.
Definition at line 909 of file Negamax.H.
References Aleph::Negamax< Domain >::limits(), and Aleph::Negamax< Domain >::limits_.
|
inlinenoexcept |
Replace the exploration policy for future runs.
Definition at line 903 of file Negamax.H.
References Aleph::Negamax< Domain >::policy(), and Aleph::Negamax< Domain >::policy_.
|
inlineprivate |
Definition at line 1046 of file Negamax.H.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Negamax< Domain >::stop_.
Referenced by Aleph::Negamax< Domain >::search_node().
|
private |
Definition at line 998 of file Negamax.H.
Referenced by Aleph::Negamax< Domain >::domain(), Aleph::Negamax< Domain >::domain(), Aleph::Negamax< Domain >::search(), Aleph::Negamax< Domain >::search(), and Aleph::Negamax< Domain >::search_node().
|
private |
Definition at line 1000 of file Negamax.H.
Referenced by Aleph::Negamax< Domain >::expansion_limit_reached(), Aleph::Negamax< Domain >::limits(), Aleph::Negamax< Domain >::search_impl(), Aleph::Negamax< Domain >::search_node(), and Aleph::Negamax< Domain >::set_limits().
|
private |
Definition at line 999 of file Negamax.H.
Referenced by Aleph::Negamax< Domain >::policy(), Aleph::Negamax< Domain >::search_impl(), and Aleph::Negamax< Domain >::set_policy().
|
private |
Definition at line 1001 of file Negamax.H.
Referenced by Aleph::Negamax< Domain >::expansion_limit_reached(), Aleph::Negamax< Domain >::search_impl(), Aleph::Negamax< Domain >::search_node(), and Aleph::Negamax< Domain >::store_transposition().
|
staticconstexpr |
Compile-time marker: Negamax only supports Depth_First strategy.
Passing ExplorationPolicy::Strategy::Best_First to this engine raises std::invalid_argument at runtime. Check this constant before constructing a policy to detect the mismatch at compile time.