poker

package module
v0.0.0-...-67cb5be Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2013 License: Apache-2.0 Imports: 1 Imported by: 1

README

poker

Go implementation of CactusKev's pokerlib with Paul Senzee's perfect hash mod integrated.

Downloading

TBD

Example

TBD

Documentation

Overview

This module exports a Go port of CactusKev's poker Hand evaluator, source available here:

http://www.suffecool.net/poker/evaluator.html

Also, it integrates paul senzee's perfect hash variant to get a 2.7x speedup:

http://www.paulsenzee.com/2006/06/some-perfect-hash.html

*

  • Created with IntelliJ IDEA.
  • User: hcombs
  • Date: 8/3/13
  • Time: 10:40 AM
  • To change this template use File | Settings | File Templates.

Index

Constants

View Source
const CARDS_IN_DECK = 52
View Source
const CARDS_IN_HAND = 5
View Source
const CARD_MASK = 0xFF
View Source
const NUM_HAND_TYPES = 10
View Source
const RANK_MASK = 0x0F00
View Source
const SUIT_MASK = 0xF000

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card uint32

func NewCard

func NewCard(rank CardRank, suit Suit) Card

func (Card) String

func (c Card) String() string

String value for a Card

type CardRank

type CardRank uint8
const (
	DEUCE CardRank = iota
	TREY
	FOUR
	FIVE
	SIX
	SEVEN
	EIGHT
	NINE
	TEN
	JACK
	QUEEN
	KING
	ACE
	NUM_CARDS
)

func (CardRank) String

func (c CardRank) String() string

type Deck

type Deck [CARDS_IN_DECK]Card

func NewDeck

func NewDeck() *Deck

Creates a new Deck initialized to the value of

type Hand

type Hand [CARDS_IN_HAND]Card

func (Hand) Eval

func (h Hand) Eval() HandScore

Evaluate a hand to produce a relative score (Lower-scoring hands are ranked higher)

func (Hand) String

func (h Hand) String() string

String value for a Hand

type HandRank

type HandRank uint8
const (
	STRAIGHT_FLUSH  HandRank = iota
	FOUR_OF_A_KIND  HandRank = iota
	FULL_HOUSE      HandRank = iota
	FLUSH           HandRank = iota
	STRAIGHT        HandRank = iota
	THREE_OF_A_KIND HandRank = iota
	TWO_PAIR        HandRank = iota
	ONE_PAIR        HandRank = iota
	HIGH_CARD       HandRank = iota
)

func HandRankFromScore

func HandRankFromScore(val int) HandRank

return the corresponding HandRank for a given value

func (HandRank) String

func (h HandRank) String() string

type HandScore

type HandScore int

The 'score' for an infividual hand of 5-card poker

func (HandScore) Rank

func (val HandScore) Rank() HandRank

type Suit

type Suit uint16
const (
	SPADE     Suit = 1 << (iota + 12)
	HEART     Suit = 1 << (iota + 12)
	DIAMOND   Suit = 1 << (iota + 12)
	CLUB      Suit = 1 << (iota + 12)
	NUM_SUITS      = iota
)

func (Suit) String

func (s Suit) String() string

Jump to

Keyboard shortcuts

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