poker-eval-0.3.0: Binding to libpoker-eval

Portability portable provisional lemmih@gmail.com None

Data.Poker

Description

Synopsis

# Evaluation

Arguments

 :: CardSet Available cards. -> HandValue

Find the strongest possible hand using the given cards.

Arguments

 :: Int Size of card set. -> CardSet Available cards. -> HandValue

Find the strongest possible hand using the given cards. This function is significantly faster than handValue if the size of the card set is constant.

Arguments

 :: CardSet Available cards. -> NumericalHandValue

Find the strongest possible hand using the given cards.

It is significantly faster to compute a NumericalHandValue than a HandValue. Use this function instead of handValue when possible.

Arguments

 :: Int Size of card set. -> CardSet Available cards. -> NumericalHandValue

Find the strongest possible hand using the given cards. This function is significantly faster than numericalHandValue if the size of the card set is constant.

It is significantly faster to compute a NumericalHandValue than a HandValue. Use this function instead of handValue_n when possible.

# Enumeration

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 7 card combinations excluding the dead cards.

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 5 card combinations excluding the dead cards.

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 4 card combinations excluding the dead cards.

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 3 card combinations excluding the dead cards.

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 2 card combinations excluding the dead cards.

Arguments

 :: (CardSet -> a -> a) -> a -> CardSet Dead cards. -> a

Strict left-fold over all 1 card combinations excluding the dead cards.

enumerateFiveCards :: Monad m => CardSet -> (CardSet -> m ()) -> m ()Source

Given a set of dead cards, enumerate over all possible selections of five cards. The generated card sets do not contain the dead cards.

# HandValue

data HandValue Source

This structure represents the value of a poker hand as a high-level ADT.

The following must be true for a HandValue to be valid:

• All kickers must be in decending order.
• No Rank may not occur twice.
• The kickers may not construct higher-value hands.

For example, NoPair Six Five Four Three Two is not a valid HandValue.

Instances

 Bounded HandValue Enum HandValue Eq HandValue Ord HandValue Show HandValue Random HandValue

Isomorphic to HandValue but computed much more efficiently.

If possible, this is the structure to use.

Isomorphic to HandValue but stored more efficiently.

This structure has the special property of being bounded and an enum. It is especially useful as an Array index.

# Cards

data Card Source

Abstract representation of a card consisting of a Rank and a Suit

Instances

 Bounded Card Enum Card Eq Card Ord Card Read Card Show Card Random Card

data Rank Source

Constructors

 Two Three Four Five Six Seven Eight Nine Ten Jack Queen King Ace

Instances

 Bounded Rank Enum Rank Eq Rank Ord Rank Show Rank Random Rank

data Suit Source

Constructors

Instances

 Bounded Suit Enum Suit Eq Suit Ord Suit Show Suit Random Suit

mkCard :: Rank -> Suit -> CardSource

Construct a card with the given rank and suit.

Inspect the rank of a card.

Inspect the suit of a card.

# Card sets

data CardSet Source

A set of cards.

Instances

 Bounded CardSet Eq CardSet Ord CardSet Read CardSet Show CardSet Random CardSet

toList :: CardSet -> [Card]Source

O(n). Convert the set to a list of cards.

fromList :: [Card] -> CardSetSource

O(n). Create a set from a list of cards.

O(1). Create a singleton set.

O(n). The number of cards in the set.

Performance note: Try to avoid using this function in an inner loop.

O(1). The empty set.

O(1). Is this the empty set?

O(1). The union of two sets.

O(1). The intersection of two sets.

O(1). Find the inverse set such that set intersection inverse = empty and set union inverse set = fromList [minBound ..].

O(1). Is the card in the set?

O(n). Count the number of cards with a specific Rank in a set.

O(n). Count the number of cards with a specific Suit in a set.

# Auxiliary functions

## HandValue

True for all NoPair hands.

True for all OnePair hands.

True for all TwoPair hands.

True for all ThreeOfAKind hands.

True for all Straight hands.

True for all Flush hands.

True for all FullHouse hands.

True for all FourOfAKind hands.

True for all StraightFlush hands.