Poker-Face is a rust virtusism exercise implementation of a Texas Hold'em poker engine. It evaluates the rank of a 5-card hand using the typical Rust match control flow construct. It determines the Rank of a 5 card hand examining the properties using Array Matching and Struct Matching MatchHandEvaluator.
Example of usage of the library, as a binary:
```rust Poker Face 0.1.0 - 🦀 for ♠️ ♣️ ♥️ ♦️ Prehashing cards...
Let's shuffle a deck...
J♥️ 7♠️ 9♠️ 10♥️ 5♥️ K♦️ K♣️ K♥️ Q♦️ 6♥️ 3♥️ J♦️ 4♥️
A♦️ J♣️ 9♣️ 5♠️ 2♠️ 4♣️ 5♦️ 3♦️ 5♣️ 6♦️ J♠️ Q♠️ 4♠️
10♠️ 7♣️ 9♥️ 7♥️ 9♦️ 3♠️ A♣️ A♥️ 7♦️ 2♦️ 10♣️ 6♣️ 4♦️
K♠️ A♠️ 8♣️ 8♥️ Q♥️ 8♦️ 2♣️ 2♥️ 3♣️ Q♣️ 6♠️ 8♠️ 10♦️
Let's take (actually, borrow) 2 hands of 5 cards each from the deck Player 1 has: J♥️ 7♠️ 9♠️ 10♥️ 5♥️
Player 2 has: K♦️ K♣️ K♥️ Q♦️ 6♥️
Sorted: K♥️ K♣️ K♦️ Q♦️ 6♥️
Player 1 has a [HighCard with a highcard of value J♥️] Player 2 has a [ThreeOfAKind]
```
As a library, there are some handy macros (newcard!, hand!, assert_rank!) implemented to deal with cards, hands and ranks. Example:
```rust assert_rank!(hand!["Ad","Kd","Qd","Jd","10d"], Rank::RoyalFlush);
assert_rank!(hand!["Kd", "Kh", "Kc", "Ks", "Qd"], Rank::FourOfAKind);
assert_rank!(hand!["2d", "2h", "Qc", "Qs", "Qd"], Rank::FullHouse);
```
or
rust
assert_eq!(newcard!["Ah"], Card::new(14, Suit::Hearts));
To run it from cargo, just type:
console
cargo run -q --
or to build and install a release from the code:
console
cargo build --release
cargo install --path .
./target/release/poker-face
If you have any suggestions for features (i.e. more functionality to implement), or if you find any problems in the code, design, interface, etc., please feel free to share them on our GitHub.
I really appreciate your feedback!