npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

poker-odds

v1.0.1

Published

A lightweight command line tool for calculating poker hand probabilities

Downloads

589

Readme

poker-odds

Latest npm version Node version required Build Status Test Coverage Donate

A lightweight command line tool for calculating poker hand probabilities. No dependencies. No huge data files.

Installation

# yarn
yarn global add poker-odds

# npm
npm install -g poker-odds

Usage

poker-odds AcKh KdQs   # any number of hands supported
                       # use .. for random cards, .... for a random hand

# options
-b, --board Td7s8d     # community cards
-i, --iterations 1000  # number of preflop simulations to run, default: 100000
-e, --exhaustive       # run all preflop simulations
-p, --possibilities    # show individual hand possibilities
-n, --no-color         # disable color output
-v, --version          # show version
-h, --help             # show help

Use --board or -b to define community cards.

--board example

Use --exhaustive or -e to run all preflop simulations. Note that this will take some time.

--exhaustive example

Use --possibilities or -p to show all possible hand outcomes. Hand possibilities are shown by default if only one hand is defined.

--possibilities example

API

The method used to calculate probabilities can be imported and used directly in a JS/node project:

import { calculateEquity } from 'poker-odds'

const hands = [['As', 'Kh'], ['Kd', 'Qs']]
const board = ['Td', '7s', '8d']
const iterations = 100000 // optional
const exhaustive = false // optional

calculateEquity(hands, board, iterations, exhaustive)

calculateEquity() returns an array of hands with the results of the simulations:

[
  {
    "hand": [
      "Ac",
      "Kh"
    ],
    "count": 990,
    "wins": 803,
    "ties": 15,
    "handChances": [
      { "name": "high card", "count": 376 },
      { "name": "one pair", "count": 479 },
      { "name": "two pair", "count": 78 },
      { "name": "three of a kind", "count": 13 },
      { "name": "straight", "count": 44 },
      { "name": "flush", "count": 0 },
      { "name": "full house", "count": 0 },
      { "name": "four of a kind", "count": 0 },
      { "name": "straight flush", "count": 0 },
      { "name": "royal flush", "count": 0 }
    ],
    "favourite": true
  },
  {
    "hand": [
      "Kd",
      "Qs"
    ],
    "count": 990,
    "wins": 172,
    "ties": 15,
    "handChances": [
      { "name": "high card", "count": 351 },
      { "name": "one pair", "count": 463 },
      { "name": "two pair", "count": 77 },
      { "name": "three of a kind", "count": 13 },
      { "name": "straight", "count": 41 },
      { "name": "flush", "count": 45 },
      { "name": "full house", "count": 0 },
      { "name": "four of a kind", "count": 0 },
      { "name": "straight flush", "count": 0 },
      { "name": "royal flush", "count": 0 }
    ],
    "favourite": false
  }
]