Giter VIP home page Giter VIP logo

poker-odds's Introduction

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
  }
]

poker-odds's People

Contributors

cookpete avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

poker-odds's Issues

Short Deck

Any chance you include the short deck variant (6-A and flush beats a full house)? Would really appreciate it!

Calculation algorithm

Hello! What is your algorithm based on? Does it only work with Texas Hold'em or can your code be adapted to other types of poker, such as Omaha, Razz, 7-Stud, Hi/Lo?

--Iterations dont work

./node_modules/.bin/poker-odds AsTh .... --board AhKdJc --iterations 99999

  board
  Ah Kd Jc

  hand      win     tie
  As Th   83.3%    5.8%
  .. ..   10.8%    5.8%

  1081 iterations in 43ms

1081 iterations always

Alternative project (emileindik/poker-odds-machine)

cookpete/poker-odds comes up with an easy cli tool, but the results aren't reliable when used with random cards (....).

For example the result for Kd 8d with 100% win ratio can not be right. This hand does loose to a lot of possible hands (e. g. pocket Aces, 2s9d, etc).

poker-odds .... Kd8d -b 2d9s4hKsJh -e

  board
  2d 9s 4h Ks Jh

  hand      win
  .. ..       ·
  Kd 8d  100.0%

  1 iterations in 1ms

As an alternative emileindik/poker-odds-machine looks promising.

not issue but question about odds

Thank You for the GREAT job, You have done on this tool.
My question is: having possibilities of high card, one pair... and other outcomes for each hand, how can I calculate the possibility of outcome for entire table, for example calculate the possibility of the winning combination on table for flush, one pair and others ?
"I mean for example 20% that the winning combination will be two pair"
I hope I could explain my question :)
and thanks again for your job.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.