pub struct Solver { /* private fields */ }Expand description
Per-strain solver.
Bound to a single strain (set at Self::new, retargetable via
Self::set_strain) and owns a search engine and a transposition
table, mirroring the per-strain Engine. Self::solve runs all
4 declarers of the configured strain for a deal; for a full 5 × 4
table across every strain use the free solve_deal / solve_deals.
The engine and TT are reused across calls so the TT can warm up. Solving a deal resets the TT — the cached entries from a previous deal (or strain) use a stale per-deal lookup table / trump and would produce incorrect hits.
Solver is Send but intentionally not Sync: the transposition
table is per-search-context and not safe for concurrent reads or
writes. Use the free solve_deals function to drive multiple
solvers in parallel.
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn new(strain: Strain) -> Self
pub fn new(strain: Strain) -> Self
Create a fresh solver for strain with the default
transposition-table memory budget. Retarget the strain later with
Self::set_strain.
Sourcepub fn with_memory(strain: Strain, default_mb: u32, max_mb: u32) -> Self
pub fn with_memory(strain: Strain, default_mb: u32, max_mb: u32) -> Self
Create a solver for strain with an explicit transposition-table
memory budget, in MiB: default_mb is the size the table shrinks
back to on reset (per solve), max_mb the ceiling before a full
reset is forced. Self::new uses the built-in defaults
(DEFAULT_MEMORY_MB / MAX_MEMORY_MB).
Bigger is better up to a plateau: a starved table full-resets and re-searches, so undersizing it explodes the node count (16/32 MiB is ~3.5× slower than the default). Correctness is unaffected at any size — a full table just resets and rebuilds. Mainly useful for capping per-thread memory in highly parallel runs.
Sourcepub fn set_strain(&mut self, strain: Strain)
pub fn set_strain(&mut self, strain: Strain)
Retarget the solver to a different strain. The next Self::solve
resets the transposition table, so no stale-trump entries survive
the change.
Sourcepub fn solve(&mut self, deal: FullDeal) -> [u8; 4]
pub fn solve(&mut self, deal: FullDeal) -> [u8; 4]
Solve the configured strain (all 4 declarers) of deal, returning
the per-seat trick row in seat order (North, East, South,
West).
Resets the transposition table for the strain’s trump, then reuses
it across the 4 declarer searches: the bounds are framed relative
to seat 0’s side, so they stay valid as the declarer — hence the
MAX side — rotates within a strain. This per-strain unit is the
grain of parallelism in solve_deals; keeping the 4 declarers
on one unit preserves that intra-strain TT reuse.
Source§impl Solver
impl Solver
Sourcepub const fn bisection_stats(&self) -> (u64, u64)
pub const fn bisection_stats(&self) -> (u64, u64)
Diagnostic: total (search_target_calls, bisection_iters)
accumulated by this solver’s engine since it was created or
Self::reset_bisection_stats was last called.
bisection_iters / search_target_calls is the average number of
alpha-beta probes per bisection driver call — a value close to 1
means the TT carries bounds between probes; ≈ 4 means each probe
re-traverses the tree from scratch.
Sourcepub const fn reset_bisection_stats(&mut self)
pub const fn reset_bisection_stats(&mut self)
Zero the bisection diagnostic counters.
Sourcepub const fn bisection_timing(&self) -> (u128, u128)
pub const fn bisection_timing(&self) -> (u128, u128)
Cumulative (iter1_nanos, later_nanos) — wall-clock time spent
in the first bisection iteration of each search_target call vs
in subsequent iterations. The ratio answers whether TT-cached
internal subtrees make later iters cheap.
Sourcepub const fn search_stats(&self) -> SearchStats
pub const fn search_stats(&self) -> SearchStats
Cumulative per-node search instrumentation (TT hit rate, move-ordering cutoff index, node-0 early-exit funnel).
All fields are zero unless the crate is built with
--features profiling.
Sourcepub fn reset_search_stats(&mut self)
pub fn reset_search_stats(&mut self)
Zero the per-node search instrumentation counters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Solver
impl RefUnwindSafe for Solver
impl Send for Solver
impl Sync for Solver
impl Unpin for Solver
impl UnsafeUnpin for Solver
impl UnwindSafe for Solver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more