# general-games

Library supporting simulation of a number of games https://github.com/cgorski/general-games

 Version on this page: 1.1.1 LTS Haskell 13.8: 1.1.1 Stackage Nightly 2019-02-20: 1.1.1 Latest on Hackage: 1.1.1

See all snapshots `general-games` appears in

Maintained by

#### Module documentation for 1.1.1

• Game
• Game.Game
• Game.Implement

# general-games

## Description

Library providing framework for simulating outcomes of a variety of games, including Poker.

## Getting Started

Suppose we want a full deck of standard playing cards:

``````>>> deck = fullDeck :: [PlayingCard]
>>> deck
``````

Thatâ€™s nice, but it might better to have a shuffled deck (your results will vary depending on the state of your RNG):

``````>>> shuffledDeck <- evalRandIO \$ shuffle deck
>>> shuffledDeck
``````

Suppose we want to draw some cards from our newly shuffled deck. There are a variety of ways that we can do this:

``````--- This will give us all poker hands in a list.
>>> allPokerHands = choose 5 shuffledDeck

--- Do we really have all poker hands?
>>> length allPokerHands
2598960 --- That seems right.

--- We can draw a poker hand by taking the head of the list.
[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Eight of Hearts]

--- Walking through the list will enumerate every combination of poker hand.
>>> take 5 allPokerHands
[[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Eight of Hearts],[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Ace of Hearts],[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Queen of Spades],[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Eight of Diamonds],[Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Nine of Clubs]]

--- It's useful to be able to draw hands from a shuffled deck.
>>> draw1_ 5 shuffledDeck
Just [Six of Diamonds,Four of Clubs,Two of Spades,Ten of Clubs,Eight of Hearts]

--- Often we might want the remainder of the deck as well.
>>> draw1 5 shuffledDeck

--- We can draw multiple hands, of multiple sizes, from a deck at once.
--- A common scenario might be to draw hands for heads-up Texas Hold'em
--- along with all of the community cards, and the remainder of the deck.
>>> draw [5,2,2] shuffledDeck
`general-games` is released under the MIT License, and Copyright 2017 Christopher A. Gorski.