1.3.10 • Published 6 years ago

poker-tools v1.3.10

Weekly downloads
21
License
MIT
Repository
github
Last release
6 years ago

poker-tools

This library is a fork of the excellent poker-odds-calculator library by rundef.

The changes are:

  1. Converted to ES6 from TypeScript.
  2. Removed the Array subclassing since this is not yet widely supported.
  3. Exposed another utility function calculateWinner([cardgroups], board).

Only Texas Hold'em is supported.

What can you do with this library:

  • Calculate equities of hands given a board (optional)
  • Calculate the winner of a set of hands given a board (optional)

Example code:

import { CardGroup, OddsCalculator } from "poker-tools";

const player1Cards = CardGroup.fromString("JhJs");
const player2Cards = CardGroup.fromString("JdQc");
const board = CardGroup.fromString("7s9sTs");
const board2 = CardGroup.fromString("7s9sTdQs3d");

const result = OddsCalculator.calculateEquity([player1Cards, player2Cards], board);

console.log(`Player #1 - ${player1Cards} - ${result.equities[0].getEquity()}%`);
console.log(`Player #2 - ${player2Cards} - ${result.equities[1].getEquity()}%`);
console.log(`Tie - ${player2Cards} - ${result.equities[1].getTiePercentage()}%`);

const result = OddsCalculator.calculateWinner([player1Cards, player2Cards], board);

console.log(result);

Output:

Player #1 - Jh Js - 75%
Player #2 - Jd Qc - 24%
Tie - Jd Qc - 1%
[ [ { index: 0, handrank: [Object] },
    { index: 1, handrank: [Object] } ] ]

Note that calculateWinner returns an array or arrays to support sidepots. Hands in the same array have the same rank.

1.3.10

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago