poker-eval-0.3.1: Binding to libpoker-eval

Portabilityportable
Stabilityprovisional
Maintainerlemmih@gmail.com
Safe HaskellNone

Data.Poker

Contents

Description

 

Synopsis

Evaluation

handValueSource

Arguments

:: CardSet

Available cards.

-> HandValue 

Find the strongest possible hand using the given cards.

handValue_nSource

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.

numericalHandValueSource

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.

numericalHandValue_nSource

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

foldlSevenCardsSource

Arguments

:: (CardSet -> a -> a) 
-> a 
-> CardSet

Dead cards.

-> a 

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

foldlFiveCardsSource

Arguments

:: (CardSet -> a -> a) 
-> a 
-> CardSet

Dead cards.

-> a 

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

foldlFourCardsSource

Arguments

:: (CardSet -> a -> a) 
-> a 
-> CardSet

Dead cards.

-> a 

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

foldlThreeCardsSource

Arguments

:: (CardSet -> a -> a) 
-> a 
-> CardSet

Dead cards.

-> a 

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

foldlTwoCardsSource

Arguments

:: (CardSet -> a -> a) 
-> a 
-> CardSet

Dead cards.

-> a 

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

foldlOneCardSource

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.

data NumericalHandValue Source

Isomorphic to HandValue but computed much more efficiently.

If possible, this is the structure to use.

data ConsecutiveHandValue Source

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

mkCard :: Rank -> Suit -> CardSource

Construct a card with the given rank and suit.

cardRank :: Card -> RankSource

Inspect the rank of a card.

cardSuit :: Card -> SuitSource

Inspect the suit of a card.

Card sets

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.

singleton :: Card -> CardSetSource

O(1). Create a singleton set.

size :: CardSet -> IntSource

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

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

empty :: CardSetSource

O(1). The empty set.

isEmpty :: CardSet -> BoolSource

O(1). Is this the empty set?

union :: CardSet -> CardSet -> CardSetSource

O(1). The union of two sets.

intersection :: CardSet -> CardSet -> CardSetSource

O(1). The intersection of two sets.

inverse :: CardSet -> CardSetSource

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

member :: CardSet -> Card -> BoolSource

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

countRank :: CardSet -> Rank -> IntSource

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

countSuit :: CardSet -> Suit -> IntSource

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

Auxiliary functions

HandValue

isNoPair :: HandValue -> BoolSource

True for all NoPair hands.

isOnePair :: HandValue -> BoolSource

True for all OnePair hands.

isTwoPair :: HandValue -> BoolSource

True for all TwoPair hands.

isThreeOfAKind :: HandValue -> BoolSource

True for all ThreeOfAKind hands.

isStraight :: HandValue -> BoolSource

True for all Straight hands.

isFlush :: HandValue -> BoolSource

True for all Flush hands.

isFullHouse :: HandValue -> BoolSource

True for all FullHouse hands.

isFourOfAKind :: HandValue -> BoolSource

True for all FourOfAKind hands.

isStraightFlush :: HandValue -> BoolSource

True for all StraightFlush hands.