Skip to main content

Crate dds_bridge

Crate dds_bridge 

Source
Expand description

§dds-bridge

Build Status Crates.io Docs.rs

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-bridge

A 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, Deal, Penalty, Solver, Strain, Seat};

// Each player holds a 13-card straight flush in one suit.
let deal: Deal = "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);
println!("{}", contract.score(10, false));

§Features

  • serde (optional)Serialize/Deserialize for all public types. Human-readable formats (JSON, YAML, TOML) round-trip through the Display/FromStr text 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::Card;
pub use deal::Deal;
pub use deal::Hand;
pub use deal::Holding;
pub use deal::Rank;
pub use deal::Seat;
pub use deal::SeatFlags;
pub use solver::Solver;

Modules§

contract
Bidding and scoring
deal
Deals and hands
solver
Solver functions for double dummy problems

Structs§

ParseStrainError
Error returned when parsing a Strain fails
ParseSuitError
Error returned when parsing a Suit fails
SuitFromNotrumpError
Error raised when converting Strain::Notrump to a suit

Enums§

Strain
Denomination, a suit or notrump
Suit
A suit of playing cards