Skip to main content

Crate dds_bridge_sys

Crate dds_bridge_sys 

Source
Expand description

§dds-bridge-sys

Build Status Crates.io Docs.rs

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.

§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).

§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

§Thread-pool management (deprecated upstream, retained for compatibility)

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 write dump.txt to the current working directory on solver errors. Intended for solver development.

Structs§

AllParResults
Boards
@brief Represents multiple bridge deals for batch analysis.
BoardsPBN
@brief Multiple boards in PBN format for batch solving.
ContractType
DDSInfo
DdTableDeal
DdTableDealPBN
DdTableDeals
DdTableDealsPBN
DdTableResults
DdTablesRes
DdsSolverConfig
DdsSolverContext
Deal
@brief Represents a bridge Deal for double dummy analysis.
DealPBN
@brief Represents a bridge Deal in PBN (Portable Bridge Notation) format.
FutureTricks
@brief Stores the result of a double dummy analysis for a single position.
ParResults
ParResultsDealer
ParResultsMaster
ParTextResults
PlayTraceBin
PlayTracePBN
PlayTracesBin
PlayTracesPBN
SolvedBoards
@brief Solutions for multiple boards.
SolvedPlay
SolvedPlays

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§

AnalyseAllPlaysBin
AnalyseAllPlaysPBN
AnalysePlayBin
AnalysePlayPBN
CalcAllTables
@brief Calculate double dummy tables for multiple deals.
CalcAllTablesPBN
@brief Calculate double dummy tables for multiple PBN deals.
CalcDDtable
@brief Calculate the double dummy table for a given Deal.
CalcDDtablePBN
@brief Calculate the double dummy table for a PBN Deal.
CalcPar
CalcParPBN
ConvertToDealerTextFormat
ConvertToSidesTextFormat
DealerPar
DealerParBin
ErrorMessage
FreeMemory
@brief Free memory used by the solver.
GetDDSInfo
Par
SetMaxThreads
@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.
SidesPar
SidesParBin
SolveAllBoards
@brief Solve multiple bridge deals in PBN format.
SolveAllBoardsBin
SolveAllChunks
SolveAllChunksBin
SolveAllChunksPBN
SolveBoard
@brief Solve a single bridge Deal using double dummy analysis.
SolveBoardPBN
@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

Type Aliases§

DdsTtKind