Struct dds_bridge::TricksRow
source · pub struct TricksRow(/* private fields */);Expand description
Tricks that each seat can take as declarer for a strain
Implementations§
source§impl TricksRow
impl TricksRow
sourcepub const fn new(n: u8, e: u8, s: u8, w: u8) -> Self
pub const fn new(n: u8, e: u8, s: u8, w: u8) -> Self
Create a new row from the number of tricks each seat can take
sourcepub const fn get(self, seat: Seat) -> u8
pub const fn get(self, seat: Seat) -> u8
Get the number of tricks a seat can take as declarer
Examples found in repository?
examples/notrump-tricks/main.rs (line 35)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
fn analyze_deals(n: usize) -> Result<(), dds::Error> {
let deals: Vec<_> = core::iter::repeat_with(|| dds::Deal::new(&mut rand::thread_rng()))
.take(n)
.collect();
let histogram = dds::solve_deals(&deals, dds::StrainFlags::NOTRUMP)?
.into_iter()
.map(|table| table[dds::Strain::Notrump])
.fold(Histogram::default(), |mut acc, row| {
let (n, e, s, w) = (
usize::from(row.get(dds::Seat::North)),
usize::from(row.get(dds::Seat::East)),
usize::from(row.get(dds::Seat::South)),
usize::from(row.get(dds::Seat::West)),
);
acc.each[n] += 1;
acc.each[e] += 1;
acc.each[s] += 1;
acc.each[w] += 1;
acc.right[n.max(s)] += 1;
acc.right[e.max(w)] += 1;
acc.max[n.max(e).max(s).max(w)] += 1;
acc
});
dbg!(&to_cumulative_probability(histogram.each)[6..]);
dbg!(&to_cumulative_probability(histogram.right)[6..]);
dbg!(&to_cumulative_probability(histogram.max)[6..]);
Ok(())
}Trait Implementations§
source§impl PartialEq for TricksRow
impl PartialEq for TricksRow
impl Copy for TricksRow
impl Eq for TricksRow
impl StructuralPartialEq for TricksRow
Auto Trait Implementations§
impl Freeze for TricksRow
impl RefUnwindSafe for TricksRow
impl Send for TricksRow
impl Sync for TricksRow
impl Unpin for TricksRow
impl UnwindSafe for TricksRow
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more