fix!: change methods `eval_5hand` `eval_7hand` to associated functions
authorMA Beaudet <ma@beaudet.xyz>
Wed, 10 Nov 2021 11:08:41 +0000 (12:08 +0100)
committerMA Beaudet <ma@beaudet.xyz>
Wed, 10 Nov 2021 11:08:41 +0000 (12:08 +0100)
src/evaluator.rs

index ce492d7..696c7ee 100644 (file)
@@ -91,16 +91,16 @@ impl Evaluator {
             Rules::Classic => hands
                 .iter()
                 .map(|h| match self.algorithm {
-                    Algorithm::CactusKev => self.eval_5hand(h.as_slice()).unwrap(),
+                    Algorithm::CactusKev => Evaluator::eval_5hand(h.as_slice()).unwrap(),
                 })
                 .enumerate()
                 .collect(),
             Rules::Holdem => hands
                 .into_iter()
                 .map(|h| match self.algorithm {
-                    Algorithm::CactusKev => self
-                        .eval_7hand([h, table.clone()].concat().as_slice())
-                        .unwrap(),
+                    Algorithm::CactusKev => {
+                        Evaluator::eval_7hand([h, table.clone()].concat().as_slice()).unwrap()
+                    }
                 })
                 .enumerate()
                 .collect(),
@@ -108,7 +108,7 @@ impl Evaluator {
         Ok(result)
     }
 
-    pub fn eval_5hand(&self, cards: &[u32]) -> Result<u16, MyError> {
+    pub fn eval_5hand(cards: &[u32]) -> Result<u16, MyError> {
         if let [c1, c2, c3, c4, c5] = cards[..5] {
             let q = (c1 | c2 | c3 | c4 | c5) >> 16;
             if c1 & c2 & c3 & c4 & c5 & 0xF000 != 0 {
@@ -125,7 +125,7 @@ impl Evaluator {
     }
 
     /// Non-optimized method of determining the best five-card hand possible of seven cards.
-    pub fn eval_7hand(&self, cards: &[u32]) -> Result<u16, MyError> {
+    pub fn eval_7hand(cards: &[u32]) -> Result<u16, MyError> {
         let mut subhand: [u32; 5] = [0; 5];
         let mut best = 9999;
 
@@ -133,7 +133,7 @@ impl Evaluator {
             for j in 0..5 {
                 subhand[j] = cards[..][PERM7[i][j] as usize];
             }
-            let q = self.eval_5hand(&subhand)?;
+            let q = Evaluator::eval_5hand(&subhand)?;
             if q < best {
                 best = q;
             }