MyNixOS website logo
Description

Texas holdem hand evaluation and simulation.

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

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)
Metadata

Version

0.1.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows