general-games-1.1.1: Library supporting simulation of a number of games

Copyright(c) 2017 Christopher A. Gorski
LicenseMIT
MaintainerChristopher A. Gorski <cgorski@cgorski.org>
Safe HaskellSafe
LanguageHaskell2010

Game.Game.Poker

Contents

Description

The Game.Game.Poker module provides operations for five card poker.

Synopsis

Poker Hand Types

data PokerHand #

A poker hand. Constructors are hidden, so any hand encapsulated in this type can be considered a valid hand.

>>> deck <- evalRandIO $ shuffle $ (fullDeck :: [PlayingCard])
>>> hand = draw1_ 5 deck
>>> hand
[Five of Diamonds,Jack of Spades,Queen of Spades,Queen of Diamonds,Jack of Hearts]
>>> pokerhand = fromJust $ mkHand hand
>>> pokerhand
PokerHand TwoPair [Five of Diamonds,Jack of Spades,Queen of Spades,Queen of Diamonds,Jack of Hearts]
>>> typeOfPokerHand pokerhand
TwoPair
>>> cardsOfPokerHand pokerhand
[Five of Diamonds,Jack of Spades,Queen of Spades,Queen of Diamonds,Jack of Hearts]
Instances
Eq PokerHand # 
Instance details

Defined in Game.Game.Poker

Show PokerHand # 
Instance details

Defined in Game.Game.Poker

data AceRank #

Indicates if a poker hand uses the Ace as a high card or a low card. AceLow is only used when an Ace is in a hand. Any hand without an Ace is considered AceHigh.

>>> 

Constructors

AceHigh 
AceLow 
Instances
Bounded AceRank # 
Instance details

Defined in Game.Game.Poker

Enum AceRank # 
Instance details

Defined in Game.Game.Poker

Eq AceRank # 
Instance details

Defined in Game.Game.Poker

Methods

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

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

Ord AceRank # 
Instance details

Defined in Game.Game.Poker

Show AceRank # 
Instance details

Defined in Game.Game.Poker

cardsOfPokerHand :: PokerHand -> [PlayingCard] #

Return the cards in a PokerHand

Building Hands

mkHand :: [PlayingCard] -> Maybe PokerHand #

Given a list of cards, find the best hand in the set. If the number of cards is not equal to five, or there are duplicate cards, mkHand returns Nothing.

Hand Type Existence Checks

isHand :: PokerHandType -> [PlayingCard] -> Bool #

Return True if a hand matches a specific PokerHandType. False otherwise.

Sets of Hand Types

allPossibleHands :: [[PlayingCard]] #

All possible hands of a full deck of playing cards

allRoyalFlush :: [[PlayingCard]] #

All royal flushes in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allStraightFlush :: [[PlayingCard]] #

All straight flushes in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allFourOfAKind :: [[PlayingCard]] #

All four-of-a-kinds in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allFullHouse :: [[PlayingCard]] #

All full houses in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allFlush :: [[PlayingCard]] #

All flushes in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allStraight :: [[PlayingCard]] #

All straights in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allThreeOfAKind :: [[PlayingCard]] #

All three-of-a-kind in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allTwoPair :: [[PlayingCard]] #

All two pairs in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allPair :: [[PlayingCard]] #

All pairs in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

allHighCard :: [[PlayingCard]] #

All high card hands in a full deck of playing cards. The current implementation traverses the entire list of allPossibleHands, and is not efficient.

Random Hands

randomHighCard :: RandomGen g => Rand g PokerHand #

Return a random hand that is not any other hand, also known as "High Card"

randomPair :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Pair

randomTwoPair :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Two Pair

randomThreeOfAKind :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Three of a Kind

randomStraight :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Straight

randomFlush :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Flush

randomFullHouse :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Full House

randomFourOfAKind :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Four of a Kind

randomStraightFlush :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Straight Flush

randomRoyalFlush :: RandomGen g => Rand g PokerHand #

Return a random hand that is a Royal Flush

Additional Hand Building Functions

mkHighCard :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a high card hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkPair :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a pair hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkTwoPair :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a two pair, and if so, return a PokerHand. Otherwise, return Nothing.

mkThreeOfAKind :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a three-of-a-kind hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkStraight :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a straight hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkFlush :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a flush hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkFullHouse :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a full house hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkFourOfAKind :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a four-of-a-kind hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkStraightFlush :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a straight flush hand, and if so, return a PokerHand. Otherwise, return Nothing.

mkRoyalFlush :: [PlayingCard] -> Maybe PokerHand #

Verify that the best hand of a set of cards is a royal flush hand, and if so, return a PokerHand. Otherwise, return Nothing.

Additional Hand Type Existence Checks

isHighCard :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a high card hand, and if so, return True. Otherwise, return False.

isPair :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a pair hand, and if so, return True. Otherwise, return False.

isTwoPair :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a two pair hand, and if so, return True. Otherwise, return False.

isThreeOfAKind :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a three-of-a-kind hand, and if so, return True. Otherwise, return False.

isStraight :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a straight hand, and if so, return True. Otherwise, return False.

isFlush :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a flush hand, and if so, return True. Otherwise, return False.

isFullHouse :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a full house hand, and if so, return True. Otherwise, return False.

isFourOfAKind :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a four-of-a-kind hand, and if so, return True. Otherwise, return False.

isStraightFlush :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a straight flush hand, and if so, return True. Otherwise, return False.

isRoyalFlush :: [PlayingCard] -> Bool #

Verify that the best hand of a set of cards is a royal flush hand, and if so, return True. Otherwise, return False.