Expand description
§dds-bridge
A Rusty API for DDS, the double-dummy solver for the game of bridge.
This crate aims to be the building block of computer bridge in Rust.
It links to dds-bridge/dds, the fundamental C++ double dummy
solver, via our system crate.
§Installation
cargo add dds-bridgeA C++ toolchain is required to build the underlying dds-bridge-sys
crate. On most Linux distributions the default g++ and make are
enough; macOS needs the Xcode Command Line Tools; Windows builds via
MSVC.
§Quick start
Parse a PBN-formatted deal, solve it for all strains and seats, and score a specific contract:
use dds_bridge::{Contract, FullDeal, Penalty, Solver, Strain, Seat};
// Each player holds a 13-card straight flush in one suit.
let deal: FullDeal = "N:AKQJT98765432... .AKQJT98765432.. \
..AKQJT98765432. ...AKQJT98765432".parse()?;
let solver = Solver::lock();
let tricks = solver.solve_deal(deal);
// 4♠ by North, scored as if 10 tricks taken, not vulnerable.
let contract = Contract::new(4, Strain::Spades, Penalty::Undoubled);
assert_eq!(contract.score(10, false), 420);§Features
serde(optional) —Serialize/Deserializefor all public types. Human-readable formats (JSON, YAML, TOML) round-trip through theDisplay/FromStrtext form; binary formats use a compact derived representation.
§Minimum supported Rust version
Rust 1.85 (the first release supporting Rust 2024 edition).
§License
Licensed under the Apache License, Version 2.0.
Re-exports§
pub use contract::Bid;pub use contract::Contract;pub use contract::Level;pub use contract::Penalty;pub use deal::Builder;pub use deal::FullDeal;pub use deal::PartialDeal;pub use hand::Card;pub use hand::Hand;pub use hand::Holding;pub use hand::Rank;pub use seat::Seat;pub use seat::SeatFlags;pub use solver::Solver;
Modules§
- contract
- Bidding, penalties, and scoring in contract bridge.
- deal
- Four-hand deal containers.
- hand
- Card primitives: ranks, cards, holdings, and hands.
- seat
- Table positions and bitsets over them.
- solver
- Double-dummy solver and par-calculation bindings built on
dds_bridge_sys.
Structs§
- Parse
Strain Error - Error returned when parsing a
Strainfails - Parse
Suit Error - Error returned when parsing a
Suitfails - Suit
From Notrump Error - Error raised when converting
Strain::Notrumpto a suit