pub struct Solver(/* private fields */);Expand description
Exclusive handle to the DDS solver
DDS functions are not reentrant, so this struct holds a lock on the global
thread pool. Acquire a Solver once and call methods on it to avoid
repeated locking.
The batch functions (CalcAllTables,
SolveAllBoardsBin) are internally
multi-threaded, so parallelism is still utilized within each call.
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn try_lock() -> Option<Self>
pub fn try_lock() -> Option<Self>
Try to acquire exclusive access to the DDS solver without blocking
Returns None if the solver is currently in use.
Sourcepub fn system_info(&self) -> SystemInfo
pub fn system_info(&self) -> SystemInfo
Get information about the underlying DDS library
Sourcepub fn solve_deal(&self, deal: FullDeal) -> TrickCountTable
pub fn solve_deal(&self, deal: FullDeal) -> TrickCountTable
Solve a single deal with sys::CalcDDtable
§Panics
Not expected — panics here are bugs. See the module-level panic policy.
§Examples
use dds_bridge::{FullDeal, Seat, Solver, Strain};
// Each player holds a 13-card straight flush in one suit.
let deal: FullDeal = "N:AKQJT98765432... .AKQJT98765432.. \
..AKQJT98765432. ...AKQJT98765432".parse()?;
let tricks = Solver::lock().solve_deal(deal);
// North holds all the spades, so North or South declaring spades
// draws trumps and takes every trick.
assert_eq!(u8::from(tricks[Strain::Spades].get(Seat::North)), 13);Sourcepub fn solve_deals(
&self,
deals: &[FullDeal],
flags: NonEmptyStrainFlags,
) -> Vec<TrickCountTable>
pub fn solve_deals( &self, deals: &[FullDeal], flags: NonEmptyStrainFlags, ) -> Vec<TrickCountTable>
Solve deals in parallel for given strains
deals: A slice of deals to solveflags: Flags of strains to solve for
§Panics
Not expected — panics here are bugs. See the module-level panic policy.
Sourcepub fn solve_board(&self, objective: Objective) -> FoundPlays
pub fn solve_board(&self, objective: Objective) -> FoundPlays
Solve a single board with sys::SolveBoard
§Panics
Not expected — panics here are bugs. See the module-level panic policy.
Sourcepub fn solve_boards(&self, args: &[Objective]) -> Vec<FoundPlays>
pub fn solve_boards(&self, args: &[Objective]) -> Vec<FoundPlays>
Solve boards in parallel
args: A slice of boards and their targets to solve
§Panics
Not expected — panics here are bugs. See the module-level panic policy.
Sourcepub fn analyse_play(&self, trace: PlayTrace) -> PlayAnalysis
pub fn analyse_play(&self, trace: PlayTrace) -> PlayAnalysis
Trace DD trick counts before and after each played card with
sys::AnalysePlayBin
§Panics
Not expected — panics here are bugs. See the module-level panic policy.
Sourcepub fn analyse_plays(&self, traces: &[PlayTrace]) -> Vec<PlayAnalysis>
pub fn analyse_plays(&self, traces: &[PlayTrace]) -> Vec<PlayAnalysis>
Trace DD trick counts in parallel with sys::AnalyseAllPlaysBin
§Panics
Not expected — panics here are bugs. See the module-level panic policy.