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 37)
27fn analyze_deals(n: usize) -> Result<(), solver::Error> {
28 let deals: Vec<_> = core::iter::repeat_with(|| Deal::new(&mut rand::rng()))
29 .take(n)
30 .collect();
31
32 let histogram = solver::solve_deals(&deals, solver::StrainFlags::NOTRUMP)?
33 .into_iter()
34 .map(|table| table[Strain::Notrump])
35 .fold(Histogram::default(), |mut acc, row| {
36 let (n, e, s, w) = (
37 usize::from(row.get(Seat::North)),
38 usize::from(row.get(Seat::East)),
39 usize::from(row.get(Seat::South)),
40 usize::from(row.get(Seat::West)),
41 );
42 acc.each[n] += 1;
43 acc.each[e] += 1;
44 acc.each[s] += 1;
45 acc.each[w] += 1;
46 acc.right[n.max(s)] += 1;
47 acc.right[e.max(w)] += 1;
48 acc.max[n.max(e).max(s).max(w)] += 1;
49 acc
50 });
51
52 dbg!(&to_cumulative_probability(histogram.each)[6..]);
53 dbg!(&to_cumulative_probability(histogram.right)[6..]);
54 dbg!(&to_cumulative_probability(histogram.max)[6..]);
55 Ok(())
56}Trait Implementations§
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