equity

package
v0.0.0-...-713b49f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2015 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package equity implements functions and structures for calculating the equity of poker hands. The hand evaluation code is based on http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#2p2

Example hands that can be parsed
*********************************
String  Combinations  Description

AJs                4  Any Ace with a Jack of the same suit.
77                 6  Any pair of Sevens.
T9o               12  Any Ten and Nine of different suits.
54                16  Any Five and Four, suited or unsuited.

AJs+              12  Any Ace with a (Jack through King) of the same suit.
77+               48  Any pair greater than or equal to Sevens.
T9o-65o           12  Any unsuited connector between 65o and T9o.

QQ+,AQs+,AK       38  Any pair of Queen or better, any AQs, and any AK
                      whether suited or not.
AhKh,7h7d          2  Ace-King of Hearts or a pair of red Sevens.

Index

Examples

Constants

This section is empty.

Variables

View Source
var NCPU int

How many cpus to use for the equity calculations.

View Source
var RANDS []*rand.Rand

Functions

func EvalHand

func EvalHand(hand []string) int32

func EvalHands

func EvalHands(board []int32, hands ...[]int32) float64

Calculate the percent of the pot the first player has won.

Example
board := cards.StoI([]string{"4s", "5h", "7d", "8c", "9c"})
hp := cards.StoI([]string{"Ac", "Ad"})
lp := cards.StoI([]string{"2c", "2d"})
fmt.Println(EvalHands(board, hp, lp))
Output:

1

func HandEquity

func HandEquity(sHand, sBoard []string, trials int) float64

HandEquity returns the equity of a player's hand based on the current board. trials is the number of Monte-Carlo simulations to do. If trials is 0, then exhaustive enumeration will be used instead.

func HandEquityP

func HandEquityP(sHand, sBoard []string, trials int) float64

Parallel version of HandEquity.

func SplitRank

func SplitRank(rank int32) (int32, int32)

Split a hand rank into two values: category and rank-within-category.

Types

This section is empty.

Notes

Bugs

  • The PRNGs are not being used in a way that guarentees their independence and their state space is much smaller than that of a deck of cards.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL