[features]
parallel = ["rayon"]
+random = ["rand"]
+default = ["random"]
[dependencies]
+rand = { version = "0.8.4", optional = true }
rayon = { version = "1.5.1", optional = true }
wasm-bindgen = "0.2.78"
--- /dev/null
+use poker_eval::{init_deck, shuffle_deck, Evaluator, Hand, Rules};
+
+fn main() {
+ let rules = Rules::Classic;
+ let deck = init_deck();
+ let mut deck = shuffle_deck(deck);
+ let mut table = Hand::new();
+
+ let player_hands: Vec<Hand> = (0..4)
+ .into_iter()
+ .map(|_| Hand::new().with_rules(&rules, &mut deck).clone())
+ .collect();
+ table.cards = deck.split_off(deck.len() - 5);
+
+ let result = Evaluator::new()
+ .with_rules(&rules)
+ .with_hands(&player_hands)
+ .with_table(&table)
+ .eval();
+
+ println!("Table: {:?}", table.cards);
+ println!("Results: {:?}", result);
+ let winner = result.iter().min_by(|a, b| a.1.cmp(&b.1)).unwrap();
+ println!("Winner: {:?}", winner);
+}
deck
}
+#[cfg(feature = "random")]
+pub fn shuffle_deck(mut deck: Vec<u32>) -> Vec<u32> {
+ use rand::prelude::*;
+ let mut rng = thread_rng();
+ deck.shuffle(&mut rng);
+ deck
+}
+
/// Returns an option of integer based on the rank and the suit of a card.
///
/// An integer is made up of four bytes. The high-order bytes are used to