pub mod array;
pub mod book;
pub mod compose;
pub mod constraint;
pub mod context;
pub mod fallback;
pub mod instinct;
pub mod map;
pub mod rules;
pub mod table;
pub mod trie;
pub mod two_over_one;
pub use array::Array;
pub use book::{Competitive, Constructive, Defensive, Family, Pair, Phase, Stance};
pub use compose::{OrElse, Versus};
pub use context::Context;
pub use instinct::instinct;
pub use map::Map;
pub use rules::Rules;
pub use table::Table;
pub use trie::{Trie, classifier};
pub use two_over_one::{two_over_one, two_over_one_strawberry};
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 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)
}
}
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));
let (classifier, _) = self.resolve(&context, auction)?;
Some(classifier.classify(hand, &context))
}
}