base

package
v0.0.0-...-62ab3a1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCombinations

func GetCombinations(cards []Card, k int) [][]Card

GetCombinations returns all unordered combinations of size k from the given cards Optimization note: returning a flat slice makes the (52 choose 7) benchmark considerably faster, but not sure we care right now

Types

type Card

type Card uint64

Card is a card This is a 64 bit int because that's what we're going to use everywhere, but a card is guaranteed to use only the lowest 8 bits Guaranteed not to be 0

func NewCard

func NewCard(rank Rank, suit Suit) Card

NewCard returns a new card

func ParseKey

func ParseKey(key Key) []Card

ParseKey parses a key into an unordered set of cards

func (Card) GetRank

func (c Card) GetRank() Rank

GetRank returns the card's rank

func (Card) GetSuit

func (c Card) GetSuit() Suit

GetSuit returns the card's suit

func (Card) String

func (c Card) String() string

type Deck

type Deck struct {
	// contains filtered or unexported fields
}

Deck is a deck of cards

func NewDeck

func NewDeck() *Deck

NewDeck returns a new unshuffled deck

func (*Deck) GetCards

func (d *Deck) GetCards() []Card

GetCards returns the remaining cards in the deck

func (*Deck) Next

func (d *Deck) Next() (Card, error)

Next deals one card from the deck

func (*Deck) Remove

func (d *Deck) Remove(remove []Card)

Remove removes a set of cards from the deck

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffles the deck

type Key

type Key uint64

Key is a hand's key

func GetKey

func GetKey(cards []Card) (Key, error)

GetKey returns an arbitrary key representing the unordered set of up to 8 cards

type Rank

type Rank int

Rank is the rank of a card, for human usage

const (
	// Two is two
	Two Rank = iota + 1
	// Three is three
	Three
	// Four is four
	Four
	// Five is five
	Five
	// Six is six
	Six
	// Seven is seven
	Seven
	// Eight is eight
	Eight
	// Nine is nine
	Nine
	// Ten is ten
	Ten
	// Jack is jack
	Jack
	// Queen is queen
	Queen
	// King is king
	King
	// Ace is ace
	Ace
)

type Score

type Score uint64

Score is a hand's score

func GetScore

func GetScore(cards []Card) (Score, error)

GetScore returns an arbitrary but ordered number representing the value of the best poker hand, out of 5, 6, or 7 cards

type Suit

type Suit int

Suit is the suit of a card, for human usage

const (
	// Club is club
	Club Suit = iota + 1
	// Diamond is diamond
	Diamond
	// Heart is heart
	Heart
	// Spade is spade
	Spade
)

Jump to

Keyboard shortcuts

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