Module poker::evaluate[][src]

Anything and everything about evaluating poker hands.

Given the specific format in which Card instances are coded, the key is figuring out how to leverage that data representation to quickly evaluate poker hands. (See [the card module] for more information).

The key is the Evaluator structure, which dynamically generates some internal HashMaps that it can use to quickly look up poker hands by a hand’s unique key, which is a product of prime numbers that each Card instance codes.

Because the Evaluator must dynamically generate its lookup tables at runtime, and the tables are decently sized, it is recommended that:

If there’s going to be a performance bottleneck associated with this crate, it will be making an Evaluator from scratch. Even so, in optimized benching, Evaluator::new only takes about 300 - 400 microseconds (there are 1 million microseconds in 1 second). Still, it is preferable to be conservative here. All Evaluator methods borrow Self immutably, so pass it around as you see fit.

Modules

static_lookup

This module is available under the non-default static_lookup feature and offers similar functionality to the Evaluator type, but evaluate comes as a free function. The main difference is that the evaluate uses a static lookup table, built into the library.

Structs

Eval

The result of a successful poker hand evaluation. When printed in Display format, shows the proper, qualified name of the poker hand.

Evaluator

This structure does all the heavy lifting of evaluating poker hands.

Enums

EvalClass

A utility enumeration type for pattern matching against the result of Eval::class. Each variant represents a class of poker hand. Royal flush is not included, but can be matched against EvalClass:StraightFlush { high_card: Rank::Ace } if desired.