poker: Texas holdem hand evaluation and simulation.

[ game, library, mit, poker, program, simulation ] [ Propose Tags ]

Please see the README on GitHub at https://github.com/ghais/poker#readme


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0
Change log ChangeLog.md
Dependencies array (>=0.5), base (>=4.11.0 && <5), binary (>=0.8), mtl (>=2.2), poker, random-fu (>=0.2.7), random-source (>=0.3), rvar (>=0.2), vector (>=0.12) [details]
License MIT
Copyright 2021 Ghais
Author Ghais
Maintainer 0x47@0x49.dev
Revised Revision 1 made by ghais at 2021-08-01T12:23:29Z
Category Game, Poker, Simulation
Home page https://github.com/ghais/poker#readme
Bug tracker https://github.com/ghais/poker/issues
Source repo head: git clone https://github.com/ghais/poker
Uploaded by ghais at 2021-08-01T03:23:02Z
Distributions NixOS:0.1.0.0
Executables poker-exe
Downloads 48 total (5 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-08-01 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for poker-0.1.0.0

[back to package description]

Poker

Haskell CI Build Status MIT license

Monte Carlo simulator for Texas Hold'em that can simulate each player probability of winning.

The simulation can proceed for any number of known and unknown cards, for example we can run a 10000 trajectory simulation of a 3 player game, where:

  1. We know that the first player has Ace of Hear, and Ten of Diamond
  2. The second player we only know that they hold the Ace of Diamond and one unknown card
  3. For the third player we know neither of the two cards.
  4. In terms of community cards we only know the flop is King of Diamond, Queen of Diamond, and Jack of Spade
example :: IO ()
example = do
  let game = Game
        {
          players =
            [
              Player (Just $ newCard Ace Heart) (Just $ newCard Ten Diamond )
            , Player (Just $ newCard Ace Diamond) Nothing
            , Player Nothing Nothing
            ]
        , flop = Just (Flop (newCard King Diamond) (newCard Queen Diamond) (newCard Jack Spade))
        , turn = Nothing
        , street = Nothing
        }
  probabilities <- simulate 10000 game
  print probabilities

Then run example in ghci

λ> example
[0.7717,0.1831,4.52e-2]
λ> 

Hand Evaluation

Contains an implementation of an efficient poker hand evaluation based on the work of Henry Lee which you can find at PokerHandEvaluator

The implementation is relatively efficient and can evaluate all possible 133,784,560 possible poker hands in less than 10 seconds.

benchmarked **evaluate/Royal flush**
**time**     **43.72 ns**  (37.72 ns .. 48.69 ns)
             **0.791 R²**  (0.543 R² .. 0.988 R²)
**mean**     **52.28 ns**  (47.82 ns .. 62.74 ns)
**std dev**  **23.79 ns**  (13.23 ns .. 38.87 ns)
variance introduced by outliers: 97% (severely inflated)

benchmarked **evaluate/Straight flush**
**time**     **47.09 ns**  (45.88 ns .. 48.31 ns)
             **0.994 R²**  (0.984 R² .. 0.997 R²)
**mean**     **47.44 ns**  (46.84 ns .. 48.83 ns)
**std dev**  **2.718 ns**  (1.640 ns .. 5.042 ns)
variance introduced by outliers: 34% (moderately inflated)

benchmarked **evaluate/Four of a kind**
**time**     **73.26 ns**  (71.52 ns .. 74.99 ns)
             **0.994 R²**  (0.989 R² .. 0.997 R²)
**mean**     **75.20 ns**  (74.22 ns .. 76.42 ns)
**std dev**  **3.749 ns**  (2.918 ns .. 4.649 ns)
variance introduced by outliers: 27% (moderately inflated)

benchmarked **evaluate/Straight**
**time**     **80.03 ns**  (77.01 ns .. 83.81 ns)
             **0.990 R²**  (0.977 R² .. 0.998 R²)
**mean**     **78.44 ns**  (77.69 ns .. 79.68 ns)
**std dev**  **3.088 ns**  (1.894 ns .. 5.316 ns)
variance introduced by outliers: 20% (moderately inflated)

benchmarked **evaluate/Full House**
**time**     **82.80 ns**  (75.65 ns .. 87.82 ns)
             **0.972 R²**  (0.953 R² .. 0.988 R²)
**mean**     **80.08 ns**  (77.53 ns .. 84.31 ns)
**std dev**  **10.48 ns**  (6.545 ns .. 15.71 ns)
variance introduced by outliers: 75% (severely inflated)

benchmarked **evaluate/One Pair**
**time**     **77.32 ns**  (74.52 ns .. 80.17 ns)
             **0.994 R²**  (0.990 R² .. 0.998 R²)
**mean**     **74.48 ns**  (73.38 ns .. 75.44 ns)
**std dev**  **3.266 ns**  (2.522 ns .. 4.255 ns)
variance introduced by outliers: 24% (moderately inflated)

benchmarked **evaluate/High Card**
**time**     **75.50 ns**  (71.19 ns .. 80.80 ns)
             **0.912 R²**  (0.733 R² .. 0.999 R²)
**mean**     **76.31 ns**  (73.65 ns .. 88.16 ns)
**std dev**  **14.98 ns**  (2.245 ns .. 33.66 ns)
variance introduced by outliers: 87% (severely inflated)