pub struct HandRating(/* private fields */);Expand description
Hand Ranking
§Overview
this is used for holdem omaha and shortdeck there are 10 hand types:
RoyalFlushStraightFlushQuadsFullHouseFlushStraightTripsTwoPairPairHighCard
§Rank representation:
- Rank as index value
- 0b0000 is Deuce and 0b1100 is Ace
- Combination of two ranks
- nCr(13, 2) is 78 so the index of combination can be fitted in 7 bits
- Combination of three ranks
- nCr(13, 3) is 286 so the index of combination can be fitted in 9 bits
- Combination of five ranks
- we just use the 13 bit flags
§Memory Layout:
u16
`RoyalFlush`/`StraightFlush`
[15, 0]: 1110ssss 00000000 // s: rank of highest card
`Quads`:
[15, 0]: 11100000 qqqqkkkk // q: rank of quads; k: rank of kicker
`FullHouse`:
[15, 0]: 11011111 ttttpppp // q: rank of trips; k: rank of pair
[15, 0]: 10111111 ttttpppp // shortdeck
`Flush`:
[15, 0]: 101rrrrr rrrrrrrr // r: set bit of 5 cards and zeros of the rest
[15, 0]: 111rrrrr rrrrrrrr // shortdeck
`Straight`:
[15, 0]: 10000000 0000ssss // s: rank of highest card
`Trips`:
[15, 0]: 0110tttt 0kkkkkkk // t: rank of trips; k: index of combination
`TwoPair`:
[15, 0]: 01000ppp ppppkkkk // p: index of combination; k: rank of kicker
`Pair`:
[15, 0]: 001ppppk kkkkkkkk // p: rank of pair; k: index of combination
`HighCard`:
[15, 0]: 000rrrrr rrrrrrrr // r: bit flags of 5 cardsTrait Implementations§
Source§impl Clone for HandRating
impl Clone for HandRating
Source§fn clone(&self) -> HandRating
fn clone(&self) -> HandRating
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HandRating
impl Debug for HandRating
Source§impl Default for HandRating
impl Default for HandRating
Source§fn default() -> HandRating
fn default() -> HandRating
Returns the “default value” for a type. Read more
Source§impl Display for HandRating
impl Display for HandRating
Source§impl From<HandRating> for HandType
impl From<HandRating> for HandType
Source§fn from(hand_ranking: HandRating) -> Self
fn from(hand_ranking: HandRating) -> Self
Extracts the categorical hand type from a HandRanking.
This implementation decodes the bit-packed HandRanking to determine
the hand type. It uses bit masking to identify the hand category from
the upper bits and additional bit checks to distinguish between hands
that share the same mask (e.g., Flush vs FullHouse, Quads vs StraightFlush).
Source§impl Ord for HandRating
impl Ord for HandRating
Source§fn cmp(&self, other: &HandRating) -> Ordering
fn cmp(&self, other: &HandRating) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for HandRating
impl PartialEq for HandRating
Source§impl PartialOrd for HandRating
impl PartialOrd for HandRating
impl Copy for HandRating
impl Eq for HandRating
impl StructuralPartialEq for HandRating
Auto Trait Implementations§
impl Freeze for HandRating
impl RefUnwindSafe for HandRating
impl Send for HandRating
impl Sync for HandRating
impl Unpin for HandRating
impl UnwindSafe for HandRating
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