croupier

package
v0.0.0-...-bd56815 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BetterThan

func BetterThan(h1 HandScore, h2 HandScore) int

func CalculateOdds

func CalculateOdds(hand []Card, sharedCardsInput []Card) float64

calculates the odds that we hav a better hand than the opponent -- if we are before the flop, the odds are taken from the initialOdds2players file the odds inside are statistics of wining with each hand calculated in 100,000,000 rounds

func Contains

func Contains(s []int, e int) bool

func DeckContains

func DeckContains(deck []Card, c Card) bool

func ExpoFunction

func ExpoFunction(odds float64, index float64) float64

func FindStraight

func FindStraight(c []int) int

func FlushOdds

func FlushOdds(cc []Card, hand []Card, remainingCardsNb float64) float64

returns the odds that the opponent has a flush. If we have a flush, it only returns the odds that the opponent has a better flush

func FourOfAKindOdds

func FourOfAKindOdds(groupByValues map[int]int, hs HandScore, hand []Card, remainingCardsNb float64) float64

returns the odds that the opponent has a four of a kind. If we have a four of a kind, it only returns the odds that the opponent has a better one

func FullHouseOdds

func FullHouseOdds(groupByValues map[int]int, hs HandScore, hand []Card, remainingCardsNb int) float64

returns the odds that the opponent has a full house. If we have a full house, it only returns the odds that the opponent has a better one

func HighCardOdds

func HighCardOdds(cc []Card, hand []Card, remainingCardsNb float64) float64

returns the odds that the opponent has the best hand without even a pair.

func IndexOf

func IndexOf(s []int, e int) int

func InstantOddsToLose

func InstantOddsToLose(handInput []Card, sharedCards []Card) float64

calculates the odds that ont opponent has a better hand than ours

func MaxInt

func MaxInt(a int, b int) int

func MinInt

func MinInt(a int, b int) int

func NormaleLawRandomization

func NormaleLawRandomization(risk float64, offset float64) float64

func OrderSliceOfInt

func OrderSliceOfInt(s []int) []int

func OrderSliceOfIntDesc

func OrderSliceOfIntDesc(s []int) []int

func PairOdds

func PairOdds(group map[int]int, hs HandScore, hand []Card, remainingCardsNb int) float64

returns the odds that the opponent has the best hand with 1 pair.

func Play

func Play(client *ws.Client, r *Round, playerIndex int, bigBlind int, totalStacks float64, coeff Coefficients, botMode bool)

func PrintDeck

func PrintDeck(client *ws.Client, d []Card)

func RaiseExpo

func RaiseExpo(x float64) float64

func RatioStacks

func RatioStacks(stack float64, opponentStack float64) float64

func RatioToWintoBet

func RatioToWintoBet(amountToBet float64, pot float64) float64

func ShowCards

func ShowCards(client *ws.Client, sp []Player)

func StraightFlushOdds

func StraightFlushOdds(sc []Card, h []Card) float64

returns the odds that the opponent has a straight flush. If we have a straight flush, it only returns the odds that the opponent has a better straight flush

func StraightOdds

func StraightOdds(commonCards []Card, hs HandScore, hand []Card) float64

returns the odds that the opponent has a straight. If we have a straight, it only returns the odds that the opponent has a better one

func ThreeInARowOdds

func ThreeInARowOdds(group map[int]int, hs HandScore, hand []Card, remainingCardsNb float64) float64

returns the odds that the opponent has the best hand with a 3 in a row.

func TwoPairsOdds

func TwoPairsOdds(group map[int]int, hs HandScore, hand []Card, remainingCardsNb float64) float64

returns the odds that the opponent has the best hand with 2 pairs.

Types

type Broker

type Broker struct{}

Broker manages the internal state of the Croupier service.

func New

func New() *Broker

New initializes a new Croupier service.

func (*Broker) Ping

func (brk *Broker) Ping() bool

Ping checks to see if the croupier's database is responding.

func (*Broker) PlayPoker

func (brk *Broker) PlayPoker(client *ws.Client)

type Card

type Card struct {
	Suit string
	Rank int
}

func AddCard

func AddCard(rank int, suit string) Card

func CopyDeck

func CopyDeck(cards []Card) []Card

func Deal

func Deal(d *[]Card, handSize int) []Card

func NewDeck

func NewDeck() []Card

func Shuffle

func Shuffle(deck []Card) []Card

func SortCards

func SortCards(c []Card) []Card

func (Card) ToString

func (c Card) ToString() string

type Coefficients

type Coefficients struct {
	Normalisation int
	Check         float64
	Raise         float64
	Fold1         float64
	Fold2         float64
	Call          float64
	AllIn         float64
}

type Config

type Config struct {
}

type Croupier

type Croupier interface {
	Ping() bool
	PlayPoker(client *ws.Client)
}

Croupier exposes all functionalities of the Croupier service.

type Game

type Game struct {
	Players         []Person
	Rounds          []Round
	SmallBlindTurn  int
	BigBlindTurn    int
	DealerTurn      int
	SmallBlindValue int
	BigBlindValue   int
	TotalStack      int
}

func LaunchGame

func LaunchGame() Game

func NewGame

func NewGame(p []Person) Game

func (Game) BetBlinds

func (g Game) BetBlinds(client *ws.Client, botMode bool)

func (*Game) EndRound

func (g *Game) EndRound(client *ws.Client, botMode bool)

func (Game) GetNumberOfPlayersAlive

func (g Game) GetNumberOfPlayersAlive() int

func (Game) GetWinner

func (g Game) GetWinner() string

func (Game) GetWinnerIndex

func (g Game) GetWinnerIndex() int

func (Game) IsGameOn

func (g Game) IsGameOn() bool

func (*Game) NewRound

func (g *Game) NewRound(client *ws.Client, botMode bool)

type HandScore

type HandScore struct {
	Score            int
	Suit             string
	Card1            int
	Card2            int
	RemainingCards   []int
	PlayerIndex      int
	IsPrecedentEqual bool
}

func CalculateFiveBestCards

func CalculateFiveBestCards(cardsInput []Card) HandScore

func (HandScore) ToString

func (s HandScore) ToString() string

type Person

type Person struct {
	Name  string
	Stack int
	IsBot bool
}

type Player

type Player struct {
	Name         string
	Cards        []Card
	Won          int
	RoundBet     int
	InitialStack int
	HasSpoken    bool
	HasFolded    bool
	IsAllIn      bool
	IsBot        bool
	Decision     float64
}

type PlayerResult

type PlayerResult struct {
	PlayerIndex int
	MaxWin      int
	HandScore   HandScore
}

func OrderResultsWithMaxWins

func OrderResultsWithMaxWins(prs []PlayerResult) []PlayerResult

type Result

type Result struct {
	Position      int
	PlayerResults []PlayerResult
}

type Round

type Round struct {
	SharedCards  []Card
	Players      []Player
	Deck         []Card
	Pot          int
	MaxBet       int
	PlayersAlive int
	PlayersAllIn int
	LimitBet     int
}

func (*Round) Bet

func (r *Round) Bet(client *ws.Client, playerIndex int, amount int, botMode bool)

func (Round) GetResults

func (r Round) GetResults() RoundResults

func (Round) IsBetTurnOver

func (r Round) IsBetTurnOver(playerIndex int) bool

type RoundResults

type RoundResults = [][]PlayerResult

type SidePot

type SidePot struct {
	Value         int
	PlayerIndexes []int
}

Jump to

Keyboard shortcuts

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