const Preflop, Flop, Turn, River
Streets.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package holdem implements the chain-independent rules of no-limit Texas Hold'em: hand evaluation, side pots and the b...
Package holdem implements the chain-independent rules of no-limit Texas Hold'em: hand evaluation, side pots and the betting state machine of one hand. Cards are indices 0..51 with rank = c % 13 (0 = Two .. 12 = Ace) and suit = c / 13.
Streets.
Hand categories, the high bits of a score.
MaxPlayers is the largest number of players in one hand.
Category returns the hand category of a score.
CategoryName names the category of a score.
Distribute awards each pot to its best eligible scores, splitting ties equally. The odd chips of a split pot all go to the winner that comes first in oddOrder (player indices clockwise from the button). It returns the amount won per player; the sum always equals the sum of the pots. It panics for more than MaxPlayers scores.
Evaluate scores the best five-card hand among 5 to 7 cards. Higher is better; equal scores tie.
OddChipOrder returns player indices clockwise starting left of the button, for hand players indexed from the small blind (heads-up: index 0 is the button). It panics unless 0 <= n <= MaxPlayers.
NewBetting posts the blinds and sets the first player to act preflop.
BuildPots splits contributions into a main pot and side pots. Folded players' chips go into the pots but they are never eligible. Chips above the largest contribution of any live player form a last pot that only the live players with that contribution can win (an uncalled bet returns to its owner this way).
Betting is the no-limit betting state of one hand. Players are indexed from the small blind (heads-up: index 0 is the button and small blind).
Act applies an action by player i. For "raise", amount is the player's total street bet after the action; it also opens the betting when nobody has bet.
CanCheck reports whether player i may check.
CanRaise reports whether player i may bet or raise: they have chips beyond a call, and either have not acted on this street or face at least a full raise since they last acted (a short all-in does not reopen the betting).
Closed reports whether no further betting is possible in the hand: one live player left, or the street is complete and at most one live player still has chips.
Live returns the number of players who have not folded.
MinRaiseTo returns the smallest legal total street bet for a non all-in bet or raise.
NextStreet resets street state and sets the first player to act. It must only be called when the current street is complete and betting not closed.
Pot returns the total contributed by all players.
StreetComplete reports whether nobody has to act on this street.
1type Player struct {
2 Stack int64 // chips behind
3 StreetBet int64 // chips put in on the current street
4 Contributed int64 // chips put in during the whole hand
5 Folded bool
6 AllIn bool
7 Acted bool // acted since the bet last increased
8 LastActBet int64 // current bet right after this player's last action this street, -1 if none
9}Player is one hand player's betting state.
Pot is one main or side pot.