From 6da70e6bfc33bf6683f1cb65fd149b35a2a493f8 Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Mon, 4 Nov 2024 14:13:47 -0800 Subject: [PATCH] nits --- src/cards.rs | 2 +- src/lib.rs | 17 +++++++++++------ src/search.rs | 5 ++++- src/stats.rs | 15 +++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/cards.rs b/src/cards.rs index 6d678a5..08a2e66 100644 --- a/src/cards.rs +++ b/src/cards.rs @@ -35,7 +35,7 @@ impl Suit { pub const ALL: [Suit; 4] = [Suit::C, Suit::D, Suit::H, Suit::S]; #[must_use] - pub fn symbol(&self) -> &str { + pub fn symbol(self) -> &'static str { match self { Suit::C => "\u{2663}", Suit::D => "\u{2666}", diff --git a/src/lib.rs b/src/lib.rs index 69c5379..52bbacf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,16 +36,21 @@ impl Player { fn index(self) -> usize { (self as u8) as usize } + + fn symbol(self) -> &'static str { + match self { + Self::W => "W", + Self::N => "N", + Self::E => "E", + Self::S => "S", + } + + } } impl std::fmt::Debug for Player { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::W => write!(f, "W"), - Self::N => write!(f, "N"), - Self::E => write!(f, "E"), - Self::S => write!(f, "S"), - } + f.write_str(self.symbol()) } } diff --git a/src/search.rs b/src/search.rs index 975da82..ce0b307 100644 --- a/src/search.rs +++ b/src/search.rs @@ -45,6 +45,7 @@ impl Lattice for Min { } } +#[derive(Debug, Clone)] pub struct InitialPosition { pub deal: Deal, pub trumps: Option, @@ -58,6 +59,7 @@ where TT: TransTable, ST: Stats, { + init: InitialPosition, state: PlayState, table: TT, stats: ST, @@ -82,6 +84,7 @@ impl, ST: Stats> SearchImpl { let deal = deal.promote_all(&mut cards); Self { + init: init.clone(), state: PlayState::::new(&deal, next), table, stats, @@ -281,7 +284,7 @@ impl, ST: Stats> Search for SearchImpl