poker-0.1.0.0: Texas holdem hand evaluation and simulation.
Copyright(c) Ghais Issa 2021
Safe HaskellNone
LanguageHaskell2010

Poker.Deck

Description

 
Synopsis

Documentation

data Suit Source #

Constructors

Club 
Diamond 
Heart 
Spade 

Instances

Instances details
Enum Suit Source # 
Instance details

Defined in Poker.Deck

Methods

succ :: Suit -> Suit #

pred :: Suit -> Suit #

toEnum :: Int -> Suit #

fromEnum :: Suit -> Int #

enumFrom :: Suit -> [Suit] #

enumFromThen :: Suit -> Suit -> [Suit] #

enumFromTo :: Suit -> Suit -> [Suit] #

enumFromThenTo :: Suit -> Suit -> Suit -> [Suit] #

Eq Suit Source # 
Instance details

Defined in Poker.Deck

Methods

(==) :: Suit -> Suit -> Bool #

(/=) :: Suit -> Suit -> Bool #

Ord Suit Source # 
Instance details

Defined in Poker.Deck

Methods

compare :: Suit -> Suit -> Ordering #

(<) :: Suit -> Suit -> Bool #

(<=) :: Suit -> Suit -> Bool #

(>) :: Suit -> Suit -> Bool #

(>=) :: Suit -> Suit -> Bool #

max :: Suit -> Suit -> Suit #

min :: Suit -> Suit -> Suit #

Read Suit Source # 
Instance details

Defined in Poker.Deck

Show Suit Source # 
Instance details

Defined in Poker.Deck

Methods

showsPrec :: Int -> Suit -> ShowS #

show :: Suit -> String #

showList :: [Suit] -> ShowS #

data Rank Source #

Constructors

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

Instances

Instances details
Enum Rank Source # 
Instance details

Defined in Poker.Deck

Methods

succ :: Rank -> Rank #

pred :: Rank -> Rank #

toEnum :: Int -> Rank #

fromEnum :: Rank -> Int #

enumFrom :: Rank -> [Rank] #

enumFromThen :: Rank -> Rank -> [Rank] #

enumFromTo :: Rank -> Rank -> [Rank] #

enumFromThenTo :: Rank -> Rank -> Rank -> [Rank] #

Eq Rank Source # 
Instance details

Defined in Poker.Deck

Methods

(==) :: Rank -> Rank -> Bool #

(/=) :: Rank -> Rank -> Bool #

Ord Rank Source # 
Instance details

Defined in Poker.Deck

Methods

compare :: Rank -> Rank -> Ordering #

(<) :: Rank -> Rank -> Bool #

(<=) :: Rank -> Rank -> Bool #

(>) :: Rank -> Rank -> Bool #

(>=) :: Rank -> Rank -> Bool #

max :: Rank -> Rank -> Rank #

min :: Rank -> Rank -> Rank #

Read Rank Source # 
Instance details

Defined in Poker.Deck

Show Rank Source # 
Instance details

Defined in Poker.Deck

Methods

showsPrec :: Int -> Rank -> ShowS #

show :: Rank -> String #

showList :: [Rank] -> ShowS #

newtype Card Source #

A card is represented as an int where the lower 4 bits representing the and the rest represents the rank ranging from 0-12.

Use newCard to construct a new card.

Constructors

Card Int 

Instances

Instances details
Eq Card Source # 
Instance details

Defined in Poker.Deck

Methods

(==) :: Card -> Card -> Bool #

(/=) :: Card -> Card -> Bool #

Ord Card Source # 
Instance details

Defined in Poker.Deck

Methods

compare :: Card -> Card -> Ordering #

(<) :: Card -> Card -> Bool #

(<=) :: Card -> Card -> Bool #

(>) :: Card -> Card -> Bool #

(>=) :: Card -> Card -> Bool #

max :: Card -> Card -> Card #

min :: Card -> Card -> Card #

Read Card Source # 
Instance details

Defined in Poker.Deck

Show Card Source # 
Instance details

Defined in Poker.Deck

Methods

showsPrec :: Int -> Card -> ShowS #

show :: Card -> String #

showList :: [Card] -> ShowS #

newCard :: Rank -> Suit -> Card Source #

Construct a new card.

data Deck Source #

Constructors

Deck !Int ![Card] 

stdDeck :: Deck Source #

construct a full 52-card playing deck. The resulting deck is not shuffled.

shuffleT :: Deck -> RVarT m Deck Source #

Shuffle a deck.

shuffle :: Deck -> RVar Deck Source #

Shuffle a deck.

draw Source #

Arguments

:: [Int]

a list of hand sizes.

-> Deck

The deck.

-> Maybe ([[Card]], Deck)

Nothing if the requested number of cards exceeds the deck size, or any of the hands is negative otherwise returns the hands and the remainder of the deck.

Draw a list of cards from the deck and group them based on the list of hands provided.

Returns the grouped cards and the remaining deck.

Arguments that are negative or exceed the length of the deck return Nothing.

For instance, to simulate a two player Hold'em game, one might wish to draw two cards for each player, and five cards for the community:

>>> deck <- runRVar (shuffle stdDeck) DevRandom
>>> fst . fromJust $ draw [2,2,5] deck
[[Ace Club,Queen Club],[Four Diamond,Nine Club],[Jack Heart,King Diamond,Three Heart,Four Club,Two Diamond]]

draw_ :: [Int] -> Deck -> Maybe [[Card]] Source #

Just like draw but throws away the deck.

draw1 :: Int -> Deck -> Maybe ([Card], Deck) Source #

The same as draw, except draw only one hand of specified size.

draw1_ :: Int -> Deck -> Maybe [Card] Source #

Same as draw1 but throws away the deck.

remove :: [Card] -> Deck -> Deck Source #

Remove a set of cards from a deck, returning the new deck.