Expand description
Poker hand strength: evaluate_5 for exactly five cards and
evaluate_7 for the best five of seven (two hole cards and a board).
Both return a HandStrength; stronger hands compare greater, and equal
strengths split the pot.
use native_solver::{evaluate_7, Card, HandCategory};
let cards = |s: &str| -> Vec<Card> { s.split(' ').map(|c| c.parse().unwrap()).collect() };
let board = cards("Ks Th 7s 4d 2s");
let hand = |hole: &str| {
let all: Vec<Card> = cards(hole).into_iter().chain(board.iter().copied()).collect();
evaluate_7(all.try_into().unwrap())
};
assert!(hand("As 9s") > hand("Kd Kc")); // a flush beats a set
assert_eq!(hand("As 9s").category(), HandCategory::Flush);Structs§
- Hand
Strength - The strength of a five-card poker hand; stronger hands compare greater.
Enums§
- Hand
Category - Hand categories, ordered from weakest to strongest.
Functions§
- evaluate_
5 - The strength of an exact five-card hand.
- evaluate_
7 - The strength of the best five-card hand out of seven cards, e.g. two hole cards and a five-card board.