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

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:

§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

§Thread-pool management

Call one of the following once at startup before any other function:

§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 write dump.txt on solver errors
  • debug-timing — function timings → timer.*.txt
  • debug-ab-stats — alpha-beta search stats → ABstats.*.txt
  • debug-tt-stats — transposition-table memory usage → TTstats.*.txt
  • debug-moves — move-generation quality → movestats.*.txt

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
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_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.