poker-evaluator
Version:
A library to evaluate 3, 5, 6 or 7 card poker hands
22 lines (21 loc) • 1.77 kB
TypeScript
import { EvaluatedHand } from './types';
import { TableOdds, PlayerOdds } from "./types/odds.interface";
export declare function evalHand(cards: string[] | number[]): EvaluatedHand;
export declare function evalCard(card: number): number;
/**
* This function takes the cards in a players hand as well as the community cards (if any) on the table.
* Given the player count at the table and the number of simulation cycles to run, this estimates the odds of winning the hand.
* Split pots are not counted as a win, so with a royal flush community hand, every player would have winning odds of 0.0.
* The more cycles used, the more precise the number will become. The time complexity of this function is a factor
* of the player count multiplied by the number of cycles. Hands with fewer cards on the table will take slightly longer.
*
* This does not use any tables, mathematical functions, or other heuristics. It simply uses a Monte Carlo method.
* This means that winning odds will vary with the same cards between runs, even with a very high cycle count.
*
* Cycles counts of 1000 tend to yield similar results to 100000 however, so unlike a chess engine, there are not
* dramatically different qualities of results with longer calculating times. In cases where the player may be aiming
* for something very unlikely, like a straight flush or four of a kind, running 30000 or more cycles will help in getting
* odds other than 0, instead yielding the correct ~0.0001.
*/
export declare function winningOddsForPlayer(hand: string[], community: string[], playerCount: number, cycles: number): PlayerOdds;
export declare function winningOddsForTable(knownPartialHands: string[][], community: string[], playerCount: number, cycles: number): TableOdds;