general-games-1.0.5: 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 Source #

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]

data AceRank Source #

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 

Building Hands

mkHand :: [PlayingCard] -> Maybe PokerHand Source #

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 Source #

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

Sets of Hand Types

allPossibleHands :: [[PlayingCard]] Source #

All possible hands of a full deck of playing cards

allRoyalFlush :: [[PlayingCard]] Source #

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]] Source #

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]] Source #

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]] Source #

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]] Source #

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

allStraight :: [[PlayingCard]] Source #

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

allThreeOfAKind :: [[PlayingCard]] Source #

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]] Source #

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]] Source #

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

allHighCard :: [[PlayingCard]] Source #

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 Source #

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

randomPair :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Pair

randomTwoPair :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Two Pair

randomThreeOfAKind :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Three of a Kind

randomStraight :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Straight

randomFlush :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Flush

randomFullHouse :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Full House

randomFourOfAKind :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Four of a Kind

randomStraightFlush :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Straight Flush

randomRoyalFlush :: RandomGen g => Rand g PokerHand Source #

Return a random hand that is a Royal Flush

Additional Hand Building Functions

mkHighCard :: [PlayingCard] -> Maybe PokerHand Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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