Skip to main content

pons_dds/
lib.rs

1//! Pure-Rust double-dummy solver for contract bridge.
2//!
3//! Reimplementation of the DDS algorithm (see the C++ vendor in
4//! `ddss-sys/vendor/src/`) with the same alpha-beta + transposition
5//! table + heuristic-ordered search at its core, but without the FFI
6//! / `cc`-crate / sanitizer-pain that the existing
7//! [`ddss`](https://crates.io/crates/ddss) and
8//! [`dds-bridge`](https://crates.io/crates/dds-bridge) wrappers carry.
9//!
10//! # v0.1 scope
11//!
12//! This release ships the [`Solver`] API: a per-strain solver that
13//! produces one strain's row of a [`TrickCountTable`] for a [`FullDeal`],
14//! plus rayon-parallel [`solve_deal`] (single-deal) and [`solve_deals`]
15//! (batch) helpers that assemble the full 5 × 4 table, and the sequential
16//! single-thread [`solve_deal_on`] for deterministic profiling. The
17//! internal substrate (position state, move generator, search engine,
18//! transposition table, and friends) remains crate-private.
19//!
20//! # Algorithm reference
21//!
22//! For each ported module, the corresponding vendor C++ file is named
23//! in the module docs. The canonical reference is
24//! [`ddss-sys/vendor/src/ABsearch.cpp`](../../../ddss-sys/vendor/src/ABsearch.cpp)
25//! for the search, plus the supporting files documented per-module.
26
27// The crate is a line-by-line port of a C++ codebase: it mixes `i32`,
28// `usize`, `u8`, and `u16` throughout its indexing and bit-twiddling
29// math, uses bridge-shorthand bindings (lho/rho, lh/rh), keeps long
30// translated functions and large fixed-size lookup tables, and mirrors
31// vendor instance methods even when they do not touch `self`. Fighting
32// these lints would obscure the correspondence with the vendor source
33// without buying real safety — invariants are guaranteed by the
34// surrounding bridge-specific context.
35#![allow(
36    clippy::cast_possible_truncation,
37    clippy::cast_possible_wrap,
38    clippy::cast_precision_loss,
39    clippy::cast_sign_loss,
40    clippy::large_stack_arrays,
41    clippy::large_stack_frames,
42    clippy::needless_pass_by_ref_mut,
43    clippy::similar_names,
44    clippy::too_many_lines,
45    clippy::unused_self
46)]
47
48pub(crate) mod convert;
49pub(crate) mod later_tricks;
50pub(crate) mod lookup;
51pub(crate) mod move_type;
52pub(crate) mod moves;
53pub(crate) mod pos;
54pub(crate) mod quick_tricks;
55pub(crate) mod search;
56pub mod solver;
57pub(crate) mod tt;
58
59pub use contract_bridge::FullDeal;
60pub use search::SearchStats;
61pub use solver::{Solver, TrickCountTable, solve_deal, solve_deal_on, solve_deals};