Expand description
§dds-bridge-sys
Generated bindings to dds-bridge/dds, the C++ double dummy solver for contract bridge.
§Usage
This library needs manual initialization! Initialize the thread pool with
SetMaxThreads
before calling other library functions:
use dds_bridge_sys as dds;
// 0 stands for automatic configuration
unsafe { dds::SetMaxThreads(0) };Also note that functions using the thread pool are not reentrant. You may want to use a mutex to ensure that only one thread is using the thread pool.
For a higher-level safe wrapper, see the dds-bridge
crate, whose Solver
type manages the mutex for you.
§Thread Safety
DDS 3 removed the internal thread pool: SetMaxThreads(N>1) is clamped to 1,
legacy batch entry points run sequentially, and the only path to parallelism
is the new per-context API exposed here as DdsSolverContext. Functions fall
into four categories.
§Modern SolverContext API — one context per OS thread
Each DdsSolverContext owns private solver state (thread-local memory,
transposition table, search state). Multiple contexts on multiple threads is
the upstream-recommended parallelism model — give each worker its own context,
never share one.
dds_solver_context_new/dds_solver_context_free— lifecycledds_solve_board— single-board solvedds_calc_dd_table/dds_calc_dd_table_pbn— full DD tabledds_calc_par/dds_calc_par_from_table— par calculationdds_solver_context_reset_for_solve/dds_solver_context_clear_tt/dds_solver_context_resize_tt/dds_solver_context_configure_tt/dds_solver_context_dispose_trans_table— TT lifecycle
§Sequential inside DDS — legacy batch APIs
These functions used to drive the internal thread pool. As of DDS 3 they
execute sequentially in a single internal thread regardless of
SetMaxThreads(N). Concurrent callers must drive parallelism from the
application side (one DdsSolverContext per worker, in preference to these).
CalcDDtable/CalcDDtablePBNCalcAllTables/CalcAllTablesPBNSolveAllBoards/SolveAllBoardsBinSolveAllChunksBin/SolveAllChunksPBN(deprecated aliases)AnalyseAllPlaysBin/AnalyseAllPlaysPBN
§Legacy single-board APIs — threadIndex=0 only
These accept a threadIndex parameter, but DDS 3 only allocates one internal
slot; any threadIndex>0 returns RETURN_THREAD_INDEX. Each call internally
constructs a fresh SolverContext, so TT state is not retained across calls.
Concurrent calls from multiple threads are safe (each gets its own internal
context) but pay full setup cost per call; prefer the modern API above for
hot paths.
§Always safe — no solver state involved
- Par:
Par,CalcPar,CalcParPBN,SidesPar,DealerPar,DealerParBin,SidesParBin - Text:
ConvertToDealerTextFormat,ConvertToSidesTextFormat - Utilities:
GetDDSInfo,ErrorMessage
§Thread-pool management (deprecated upstream, retained for compatibility)
SetMaxThreads— initialize (0= auto-configure)SetResources— set memory and thread limits
Both functions still need to be called once at startup before any legacy entry
point. They are no-ops for the modern DdsSolverContext path, which manages
its own resources per instance.
§Cargo features
debug-dump(off by default) — let DDS writedump.txtto the current working directory on solver errors. Intended for solver development.
Structs§
- AllPar
Results - Boards
- @brief Represents multiple bridge deals for batch analysis.
- BoardsPBN
- @brief Multiple boards in PBN format for batch solving.
- Contract
Type - DDSInfo
- DdTable
Deal - DdTable
DealPBN - DdTable
Deals - DdTable
DealsPBN - DdTable
Results - DdTables
Res - DdsSolver
Config - DdsSolver
Context - Deal
- @brief Represents a bridge Deal for double dummy analysis.
- DealPBN
- @brief Represents a bridge Deal in PBN (Portable Bridge Notation) format.
- Future
Tricks - @brief Stores the result of a double dummy analysis for a single position.
- ParResults
- ParResults
Dealer - ParResults
Master - ParText
Results - Play
Trace Bin - Play
TracePBN - Play
Traces Bin - Play
TracesPBN - Solved
Boards - @brief Solutions for multiple boards.
- Solved
Play - Solved
Plays
Constants§
- DDS_
HANDS - < Number of hands (N/E/S/W)
- DDS_
NOTRUMP - < No trump strain index
- DDS_
STRAINS - < Number of strains (4 suits + no trump)
- DDS_
SUITS - < Number of suits (S/H/D/C)
- DDS_
TT_ KIND_ LARGE - DDS_
TT_ KIND_ SMALL - DDS_
VERSION - MAXNOOFBOARDS
- MAXNOOFTABLES
- RETURN_
CARD_ COUNT - RETURN_
CHUNK_ SIZE - RETURN_
DUPLICATE_ CARDS - RETURN_
FIRST_ WRONG - RETURN_
MODE_ WRONG_ HI - RETURN_
MODE_ WRONG_ LO - RETURN_
NO_ FAULT - RETURN_
NO_ SUIT - RETURN_
PBN_ FAULT - RETURN_
PLAYED_ CARD - RETURN_
PLAY_ FAULT - RETURN_
SOLNS_ WRONG_ HI - RETURN_
SOLNS_ WRONG_ LO - RETURN_
SUIT_ OR_ RANK - RETURN_
TARGET_ TOO_ HIGH - RETURN_
TARGET_ WRONG_ HI - RETURN_
TARGET_ WRONG_ LO - RETURN_
THREAD_ CREATE - RETURN_
THREAD_ INDEX - RETURN_
THREAD_ MISSING - RETURN_
THREAD_ WAIT - RETURN_
TOO_ MANY_ BOARDS - RETURN_
TOO_ MANY_ CARDS - RETURN_
TOO_ MANY_ TABLES - RETURN_
TRUMP_ WRONG - RETURN_
UNKNOWN_ FAULT - RETURN_
ZERO_ CARDS - TEXT_
CARD_ COUNT - TEXT_
CHUNK_ SIZE - TEXT_
DUPLICATE_ CARDS - TEXT_
FIRST_ WRONG - TEXT_
MODE_ WRONG_ HI - TEXT_
MODE_ WRONG_ LO - TEXT_
NO_ FAULT - TEXT_
NO_ SUIT - TEXT_
PBN_ FAULT - TEXT_
PLAYED_ CARD - TEXT_
PLAY_ FAULT - TEXT_
SOLNS_ WRONG_ HI - TEXT_
SOLNS_ WRONG_ LO - TEXT_
SUIT_ OR_ RANK - TEXT_
TARGET_ TOO_ HIGH - TEXT_
TARGET_ WRONG_ HI - TEXT_
TARGET_ WRONG_ LO - TEXT_
THREAD_ CREATE - TEXT_
THREAD_ INDEX - TEXT_
THREAD_ MISSING - TEXT_
THREAD_ WAIT - TEXT_
TOO_ MANY_ BOARDS - TEXT_
TOO_ MANY_ CARDS - TEXT_
TOO_ MANY_ TABLES - TEXT_
TRUMP_ WRONG - TEXT_
UNKNOWN_ FAULT - TEXT_
ZERO_ CARDS
Statics§
- bit_
map_ ⚠rank - @brief Bitmask representation for card ranks. Maps absolute rank (0-15) to bitmask (0x0000-0x2000). Rank 2->0x0001, Rank 3->0x0002, …, Rank Ace(14)->0x1000. Indices 0, 1, 15 are sentinel values.
- card_
hand ⚠ - @brief Character representation for hands. Maps hand (0-3) to character: N/E/S/W (North/East/South/West).
- card_
rank ⚠ - @brief Character representation for card ranks. Maps absolute rank (0-15) to printable character. Valid ranks: 2-A map to ‘2’-‘A’, Ace is ‘A’, sentinel values are ‘x’, ‘-’.
- card_
suit ⚠ - @brief Character representation for suits. Maps suit index (0-4) to character: S/H/D/C/N (no trump).
- lho⚠
- @brief Left-hand opponent for each hand (index -> hand value). Precomputed lookup: lho[i] gives the hand number of the player sitting to hand i’s left. Values: lho[0]=1 (North’s LHO is East), lho[1]=2 (East’s LHO is South), lho[2]=3 (South’s LHO is West), lho[3]=0 (West’s LHO is North)
- partner⚠
- @brief Partner for each hand (index -> hand value). Precomputed lookup: partner[i] gives the hand number of the player partnered with hand i. Values: partner[0]=2 (North’s partner is South), partner[1]=3 (East’s partner is West), partner[2]=0 (South’s partner is North), partner[3]=1 (West’s partner is East)
- rho⚠
- @brief Right-hand opponent for each hand (index -> hand value). Precomputed lookup: rho[i] gives the hand number of the player sitting to hand i’s right. Values: rho[0]=3 (North’s RHO is West), rho[1]=0 (East’s RHO is North), rho[2]=1 (South’s RHO is East), rho[3]=2 (West’s RHO is South)
Functions§
- Analyse
AllPlays ⚠Bin - Analyse
AllPlaysPBN ⚠ - Analyse
Play ⚠Bin - Analyse
PlayPBN ⚠ - Calc
AllTables ⚠ - @brief Calculate double dummy tables for multiple deals.
- Calc
AllTablesPBN ⚠ - @brief Calculate double dummy tables for multiple PBN deals.
- CalcD
Dtable ⚠ - @brief Calculate the double dummy table for a given Deal.
- CalcD
DtablePBN ⚠ - @brief Calculate the double dummy table for a PBN Deal.
- CalcPar⚠
- Calc
ParPBN ⚠ - Convert
ToDealer ⚠Text Format - Convert
ToSides ⚠Text Format - Dealer
Par ⚠ - Dealer
ParBin ⚠ - Error
Message ⚠ - Free
Memory ⚠ - @brief Free memory used by the solver.
- GetDDS
Info ⚠ - Par⚠
- SetMax
Threads ⚠ - @brief Set the maximum number of threads used by the solver.
- SetResources⚠
- @brief Set memory and thread resources for the solver.
- SetThreading⚠
- @brief Set the threading backend used by the solver.
- Sides
Par ⚠ - Sides
ParBin ⚠ - Solve
AllBoards ⚠ - @brief Solve multiple bridge deals in PBN format.
- Solve
AllBoards ⚠Bin - Solve
AllChunks ⚠ - Solve
AllChunks ⚠Bin - Solve
AllChunksPBN ⚠ - Solve
Board ⚠ - @brief Solve a single bridge Deal using double dummy analysis.
- Solve
BoardPBN ⚠ - @brief Solve a single bridge Deal in PBN format using double dummy analysis.
- dds_
calc_ ⚠dd_ table - dds_
calc_ ⚠dd_ table_ pbn - dds_
calc_ ⚠par - dds_
calc_ ⚠par_ from_ table - dds_
solve_ ⚠board - dds_
solver_ ⚠context_ clear_ tt - dds_
solver_ ⚠context_ configure_ tt - dds_
solver_ ⚠context_ dispose_ trans_ table - dds_
solver_ ⚠context_ free - dds_
solver_ ⚠context_ new - dds_
solver_ ⚠context_ reset_ for_ solve - dds_
solver_ ⚠context_ resize_ tt