Pons
This library provides tools for analyzing and simulating hands in the card game contract bridge. It is named after an anatomical part of the brainstem and also "bridge" in Latin.
Modules
bidding—Trie-based representation of a bidding system. Auction primitives (Call,Auction, etc.) live in thecontract-bridgecrate.stats— numerically stable accumulators and double-dummy par scoring over histograms.
Card sets and shuffling live in contract-bridge::deck; hand-evaluation kernels in contract-bridge::eval.
Feature flags
serde— deriveSerialize/Deserializefor the library's value types. Off by default.
Quick start
Deal 10 random hands and evaluate the North hand with several point counts:
use Seat;
use full_deal;
use ;
let mut rng = rng;
for _ in 0..10
Estimate NS par from random fill-in deals (requires ddss's solver,
linked via ddss-sys in dev-dependencies; see
examples/average-ns-par):
use deck;
use ;
use ;
use stats;
# let north_hand: Hand = "T9762.AT54.JT75.".parse.unwrap;
# let south_hand: Hand = "A.KQ962.A86.Q642".parse.unwrap;
let cards = new
.north
.south
.build_partial
.expect;
let solutions = lock.solve_deals;
let par = average_ns_par;
Examples
The examples/ directory has runnable programs:
check-nltcandcheck-zar— validate hand-evaluation methods against double-dummy results.average-ns-par— Monte-Carlo NS par score for a partial deal.defend-2sx-or-3nt— compare expected NS score from defending 2♠× vs declaring 3NT.
Run any of them with cargo run --example <name>.
Two examples that don't need pons live one level down the stack:
generate-deals
in contract-bridge and
notrump-tricks
in ddss (with a parallel
copy
in dds-bridge).