pub mod american;
pub mod array;
pub mod book;
pub mod compose;
pub mod constraint;
pub mod context;
#[cfg(feature = "dd")]
pub mod ev;
pub mod fallback;
pub mod features;
pub mod inference;
pub mod instinct;
pub mod map;
#[cfg(feature = "neural-floor")]
pub mod neural;
#[cfg(feature = "neural-floor")]
pub mod neural_floor;
pub mod rules;
pub mod sampler;
#[cfg(feature = "search")]
pub mod search_floor;
pub mod table;
pub mod tags;
pub mod trie;
pub mod verify;
pub use american::american;
#[cfg(feature = "neural-floor")]
pub use american::{
american_neural, american_neural_search, american_neural_v2, american_neural_v3,
};
#[cfg(feature = "search")]
pub use american::{american_search, american_search_with};
pub use array::Array;
pub use book::{Competitive, Constructive, Defensive, ExplainedRule, Family, Pair, Phase, Stance};
pub use compose::{OrElse, Versus};
pub use context::Context;
#[cfg(feature = "dd")]
pub use ev::{ev, ev_all};
pub use features::{FEATURES_LEN, FEATURES_VERSION, features};
pub use inference::{
Inference, Inferences, Range, Relative, set_alert_reading, set_control_bid_reading,
set_fallback_projection, set_nt_invite_inference, set_rubens_transfer_reading,
};
pub use instinct::instinct;
pub use map::Map;
pub use rules::{Alert, Rules};
pub use sampler::sample_layouts;
#[cfg(feature = "search")]
pub use search_floor::{SearchBook, SearchFloor, american_search_book};
pub use table::Table;
pub use trie::{Trie, classifier};
pub use verify::{Report, accepts, compare};
use contract_bridge::Hand;
use contract_bridge::auction::{Call, RelativeVulnerability};
pub trait System {
fn classify(
&self,
hand: Hand,
vul: RelativeVulnerability,
auction: &[Call],
) -> Option<array::Logits>;
fn authored_at(&self, vul: RelativeVulnerability, auction: &[Call]) -> bool {
let _ = (vul, auction);
true
}
fn vs<B: System>(self, other: B) -> Versus<Self, B>
where
Self: Sized,
{
Versus::new(self, other)
}
fn or_else<B: System>(self, other: B) -> OrElse<Self, B>
where
Self: Sized,
{
OrElse::new(self, other)
}
}
impl<S: System + ?Sized> System for &S {
fn classify(
&self,
hand: Hand,
vul: RelativeVulnerability,
auction: &[Call],
) -> Option<array::Logits> {
(**self).classify(hand, vul, auction)
}
fn authored_at(&self, vul: RelativeVulnerability, auction: &[Call]) -> bool {
(**self).authored_at(vul, auction)
}
}
impl System for Trie {
fn classify(
&self,
hand: Hand,
vul: RelativeVulnerability,
auction: &[Call],
) -> Option<array::Logits> {
let context = Context::new(vul, auction).with_prefixes(self.common_prefixes(auction));
self.classify_floored(hand, &context, auction)
.map(|(logits, _)| logits)
}
fn authored_at(&self, vul: RelativeVulnerability, auction: &[Call]) -> bool {
let context = Context::new(vul, auction).with_prefixes(self.common_prefixes(auction));
matches!(
self.resolve(&context, auction),
Some((_, prov)) if prov.fallback.is_none() || prov.depth > 0
)
}
}