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
Functions fall into four categories:
§Non-reentrant — exclusive thread-pool access required
These functions drive the internal thread pool and must not be called concurrently. Protect all calls with a single mutex:
CalcDDtable/CalcDDtablePBN— compute a full DD table (threads per strain)CalcAllTables/CalcAllTablesPBN— batch DD tablesSolveAllBoards/SolveAllBoardsBin— batch board solvingSolveAllChunksBin/SolveAllChunksPBN(deprecated aliases)AnalyseAllPlaysBin/AnalyseAllPlaysPBN— batch play analysis
§Reentrant — explicit threadIndex parameter
These are safe to call from multiple threads simultaneously. Each concurrent
call must use a distinct threadIndex in 0..SetMaxThreads(0).
§Always safe — no thread pool involved
- Par:
Par,CalcPar,CalcParPBN,SidesPar,DealerPar,DealerParBin,SidesParBin - Text:
ConvertToDealerTextFormat,ConvertToSidesTextFormat - Utilities:
GetDDSInfo,ErrorMessage
§Thread-pool management
Call one of the following once at startup before any other function:
SetMaxThreads— initialize (0= auto-configure)SetResources— set memory and thread limits
§Cargo features
All features are off by default. The debug-* diagnostic features cause the
C++ solver to write per-thread .txt files into the current working directory
at runtime; they are intended for solver development, not production use.
debug-dump— let DDS writedump.txton solver errorsdebug-timing— function timings →timer.*.txtdebug-ab-stats— alpha-beta search stats →ABstats.*.txtdebug-tt-stats— transposition-table memory usage →TTstats.*.txtdebug-moves— move-generation quality →movestats.*.txt
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 - 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_
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.