48# ifndef SEARCH_MOVE_ORDERING_H
49# define SEARCH_MOVE_ORDERING_H
85template <
typename Move,
typename Priority>
105template <
typename Move,
bool Supported = std::equality_comparable<Move>>
109template <
typename Move>
114 static constexpr bool supported =
false;
131 static void record(
const size_t,
const Move &)
noexcept
138template <
typename Move>
143 static constexpr bool supported =
true;
159 return depth < primary_.size()
160 and ((primary_[depth].has_value()
and *primary_[depth] == move)
161 or (secondary_[depth].has_value()
and *secondary_[depth] == move));
168 void record(
const size_t depth,
const Move &move)
170 ensure_depth(depth + 1);
171 if (primary_[depth].has_value()
and *primary_[depth] == move)
174 secondary_[depth] = primary_[depth];
175 primary_[depth] = move;
183 primary_.append(std::optional<Move>{});
184 secondary_.append(std::optional<Move>{});
207 template <
typename Key>
214 template <
typename Key>
227template <
typename Key,
252 if (
auto *entry =
table_.search(key); entry !=
nullptr)
253 return entry->second;
264 if (
auto *entry =
table_.search(key); entry !=
nullptr)
266 entry->second +=
bonus;
294template <
typename Move,
typename Priority,
typename BetterPriority>
300 if (moves.size() < 2)
310 return lhs.history_score >
rhs.history_score;
318 return lhs.ordinal <
rhs.ordinal;
Simple dynamic array with automatic resizing and functional operations.
Sparse history heuristic table over Aleph hash maps.
size_t score(const Key &key) const noexcept
Read the current score for a move key.
static constexpr bool supported
Marker indicating that this table tracks history.
void clear() noexcept
Reset all history scores to zero.
void record(const Key &key, const size_t bonus=1)
Increment the history score for a move key.
Key Key_Type
Type of move keys.
static void record(const size_t, const Move &) noexcept
No-op.
static void clear() noexcept
No-op.
static bool is_killer(const size_t, const Move &) noexcept
Always returns false.
void clear() noexcept
Remove all recorded killer moves.
Array< std::optional< Move > > primary_
Array< std::optional< Move > > secondary_
void ensure_depth(const size_t required)
bool is_killer(const size_t depth, const Move &move) const noexcept
Return true if move is in a killer slot for depth.
void record(const size_t depth, const Move &move)
Record a move that caused a cutoff at depth.
Two-slot killer heuristic table indexed by search depth.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
void sort_ranked_moves(Array< RankedMove< Move, Priority > > &moves, BetterPriority better_priority, const bool prefer_killer, const bool prefer_history)
Sort one materialized move batch using priority and optional hooks.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
MoveOrderingMode
Built-in move-ordering modes supported by the framework.
@ Estimated_Bound
Rank successors by an optimistic child bound.
@ Domain
Preserve the order emitted by for_each_successor().
@ Estimated_Score
Rank successors by a cheap heuristic score estimate.
void introsort(T *a, const long l, const long r, const Compare &cmp=Compare())
Sort an array using introsort (introspective sort).
Open addressing hash map using linear probing.
Statistics collected by engines that reorder successor batches.
size_t priority_estimates
Number of score/bound estimates computed for ordering.
size_t killer_hits
Moves promoted because they matched a killer slot.
size_t history_hits
Moves promoted because they had non-zero history.
size_t ordered_moves
Number of individual moves considered by ordering.
size_t ordered_batches
Number of successor batches materialized and ordered.
Null history heuristic hook used when a domain has no move key.
static constexpr bool supported
Marker indicating that this table does nothing.
static void record(const Key &, const size_t=1) noexcept
No-op.
static size_t score(const Key &) noexcept
Always returns zero.
static void clear() noexcept
No-op.
One move plus the metadata used by ordering comparators.
Priority priority
Cheap heuristic priority (lower or higher depending on engine).
size_t ordinal
Original order from successor generator (tie-breaker).
size_t history_score
Accumulated history heuristic score.
Move move
The candidate move.
bool killer
True if this move matched a killer slot.
Dynamic array container with automatic resizing.
Unified hash table interface.
Comprehensive sorting algorithms and search utilities for Aleph-w.