crapssim.bet
Classes
Represents the outcome of a bet |
|
A generic bet for the craps table. |
|
A bet that has winning numbers, losing numbers, and payout ratios |
|
A bet that has fixed winning and losing numbers and payout ratio |
|
Pass Line bet in craps. |
|
Come bet in craps. |
|
Don't Pass bet in craps. |
|
Don't Come bet in craps. |
|
Odds bet (for PassLine, DontPass, Come, or Dontcome) in craps. |
|
Flat line bet on a box number; point must be ON and odds obey table policy. |
|
Place bet (on 4, 5, 6, 8, 9, or 10) in craps. |
|
True-odds bet on 4/5/6/8/9/10 that charges vig per table policy. |
|
True-odds bet against 4/5/6/8/9/10, paying if 7 arrives first. |
|
Field bet in craps. |
|
Craps and Eleven (C & E) bet in craps. |
|
Any 7 bet (also known as Big Red) in craps. |
|
Two (Snake Eyes) bet in craps. |
|
Three bet in craps. |
|
Yo (Eleven) bet in craps. |
|
Boxcars (Midnight) bet in craps. |
|
Any Craps bet in craps. |
|
One-roll bet split across 2, 3, 11, and 12; loses on all other totals. |
|
One-roll bet covering Horn numbers plus 7; pays break-even on 7. |
|
Even-money bet that wins on 6 before 7. |
|
Even-money bet that wins on 8 before 7. |
|
Hard Way bet (on 4, 6, 8, or 10) in craps. |
|
Hop bet in craps. |
|
Fire bet in craps. |
|
All bet (part of All/Tall/Small bets) in craps. |
|
Tall bet (part of All/Tall/Small bets) in craps. |
|
Small bet (part of All/Tall/Small bets) in craps. |
Module Contents
- class crapssim.bet.BetResult
Represents the outcome of a bet
This class is used by all Bets for consistency in determining whether the bet won, lost or pushed. It provides properties to analyze the bet outcome and its impact on a bankroll.
- amount: float
The monetary value representing the bet outcome.
- remove: bool
Flag indicating whether this bet result should be removed from table.
- bet_amount: float = 0
The monetary value of the original bet size. Needed only for bets that push and return the wager to the player. Default is zero for quick results that can define wins and losses by comparing against zero.
- property won: bool
Returns True if the bet won (amount more than initial bet).
- property lost: bool
Returns True if the bet lost (negative amount).
- property pushed: bool
Returns True if the bet tied (zero amount).
- property bankroll_change: float
Calculates the change to the bankroll (amount if bet won, zero otherwise).
- class crapssim.bet.Bet(amount: SupportsFloat)
Bases:
abc.ABCA generic bet for the craps table.
The high-level class that defines most of the core bet methods. All bets will be a subclass of this.
- amount: float
Wagered amount for the bet.
- abstractmethod get_result(table: Table) BetResult
Core bet logic that determines the result.
This determines the ultimate amount and whether the bet needs to be removed, which is indicated with a BetResult object.
- update_number(table: Table)
Update the bet’s number, if applicable
This method is required by Come and DontCome bets to update their number after the first roll. Since this method is used by the Table, it defaults to doing nothing for a generic bet.
- is_removable(table: Table) bool
Checks whether the bet is removable. May depend on the table conditions (e.g. if point is On).
- Returns:
True if the bet is removable, otherwise false.
- is_allowed(player: Player) bool
Checks whether the bet is allowed to be placed on the given table. May depend on the player’s bets also (e.g. for odds bets).
- Returns:
True if the bet is allowed, otherwise false.
- property _placed_key: Hashable
- property _hash_key: Hashable
- __eq__(other: object) bool
- __hash__() int
- __repr__() str
- __radd__(other)
- __rsub__(other)
- __str__() str
- class crapssim.bet._WinningLosingNumbersBet(amount: SupportsFloat)
Bases:
Bet,abc.ABCA bet that has winning numbers, losing numbers, and payout ratios
These values (possibly depending on the table) are used to calculate the result.
- get_result(table: Table) BetResult
Core bet logic that determines the result.
Wins are based on having dice total in the winning numbers (which may depend on the table), which will pay the payout_ratio times the bet amount plus the original bet amount back. Losses happen when dice total is in the losing numbers, which result in a loss of the original bet amount. Otherwise the bet stays on the table.
- abstractmethod get_winning_numbers(table: Table) list[int]
Returns the winnings numbers, based on table features
- class crapssim.bet._SimpleBet(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBet,abc.ABCA bet that has fixed winning and losing numbers and payout ratio
Essentially, the numbers and payout ratio can be known at instantiation and don’t depend on the table.
- winning_numbers: list[int] = []
Winning numbers for the bet
- losing_numbers: list[int] = []
Losing numbers for the bet
- payout_ratio: int = 1
Payout ratio for the bet
- class crapssim.bet.PassLine(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetPass Line bet in craps.
A bet where the player wins if the first roll is 7 or 11, loses if the first roll is 2, 3, or 12, and establishes a point number for subsequent rolls. Once a point is set, the player wins by rolling the point number again before rolling a 7. Pays 1 to 1.
- get_winning_numbers(table: Table) list[int]
Winnings numbers are 7, 11 before point is set, and the point number after point is set. Uses table to determine the point number and status.
- get_losing_numbers(table: Table) list[int]
Losing numbers are 2, 3, 12 before point is set, and 7 after point is set. Uses table to determine the point number and status.
- class crapssim.bet.Come(amount: SupportsFloat, number: int | None = None)
Bases:
_WinningLosingNumbersBetCome bet in craps.
Similar to the Pass Line bet, but can be placed after a point is established. The first roll determines the Come bet’s point number, but also wins on 7, 11 and loses on 2, 3, 12. The bet wins in subsequent rolls if the point number is rolled before a 7, and loses if a 7 is rolled before the point number. Pays 1 to 1.
- get_winning_numbers(table: Table) list[int]
Winnings numbers are 7, 11 before the number is set, and the number after it is set. Number is stored within the bet.
- get_losing_numbers(table: Table) list[int]
Losing numbers are 2, 3, 12 before the number is set, and 7 after it is set. Number is stored within the bet.
- update_number(table: Table)
Update the bet’s number to the first number rolled if it’s in (4, 5, 6, 8, 9, 10).
- is_removable(table: Table) bool
Come bet is removable is it’s number has not been established yet (first roll).
- Returns:
True if the bet is removable, otherwise false.
- is_allowed(player: Player) bool
Come bet is only allowed if the table’s point is on (accessed via player).
- Returns:
True if the bet is allowed, otherwise false.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.DontPass(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetDon’t Pass bet in craps.
The opposite of the Pass Line bet. The player wins if the first roll is 2 or 3, pushes on 12, and loses if the first roll is 7 or 11. After a point is established, the player wins by rolling a 7 before the point number. Bet pays 1 to 1.
- get_winning_numbers(table: Table) list[int]
Winnings numbers are 2 or 3 before point is set, and 7 after point is set. Uses table to determine the point number and status.
- class crapssim.bet.DontCome(amount: SupportsFloat, number: int | None = None)
Bases:
_WinningLosingNumbersBetDon’t Come bet in craps.
Similar to the Don’t Pass bet, but can be placed after a point is established, but also wins on 2, 3, pushes on 12, and loses on 7 or 11. The first roll determines the Don’t Come bet’s number. The bet wins in subsequent rolls if a 7 is rolled before the point number, and loses if the number is rolled before a 7. Pays 1 to 1.
- update_number(table: Table)
Update the bet’s number, if applicable
This method is required by Come and DontCome bets to update their number after the first roll. Since this method is used by the Table, it defaults to doing nothing for a generic bet.
- is_allowed(player: Player) bool
Don’t Come is only allowed if the table’s point is on (accessed via player).
- Returns:
True if the bet is allowed, otherwise false.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Odds(base_type: type[PassLine | DontPass | Come | DontCome | Put], number: int, amount: float, always_working: bool = False)
Bases:
_WinningLosingNumbersBetOdds bet (for PassLine, DontPass, Come, or Dontcome) in craps.
A supplementary bet placed behind Pass Line, Don’t Pass, Come, or Don’t Come bets. Offers true odds payouts, meaning the house has no edge. The payout varies depending on the point number and whether it’s a “light side” (Pass/Come) or “dark side” (Don’t Pass/Don’t Come) bet.
- base_type
- number
- always_working = False
- property light_side: bool
- property dark_side: bool
- get_result(table: Table) BetResult
Core bet logic that determines the result.
Wins are based on having dice total in the winning numbers (which may depend on the table), which will pay the payout_ratio times the bet amount plus the original bet amount back. Losses happen when dice total is in the losing numbers, which result in a loss of the original bet amount. Otherwise the bet stays on the table.
- is_allowed(player: Player) bool
Odds are allowed if they do not exceed the table maximums.
- Returns:
True if the bet is allowed, otherwise false.
- _get_always_working_repr() str
Since the default is false, only need to print when True
- property _placed_key: Hashable
- __repr__()
- __str__() str
- class crapssim.bet.Put(number: int, amount: SupportsFloat)
Bases:
_SimpleBetFlat line bet on a box number; point must be ON and odds obey table policy.
- losing_numbers: list[int] = [7]
Losing numbers for the bet
- number
- winning_numbers
Winning numbers for the bet
- payout_ratio = 1.0
Payout ratio for the bet
- is_allowed(player: Player) bool
Checks whether the bet is allowed to be placed on the given table. May depend on the player’s bets also (e.g. for odds bets).
- Returns:
True if the bet is allowed, otherwise false.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Place(number: int, amount: SupportsFloat)
Bases:
_SimpleBetPlace bet (on 4, 5, 6, 8, 9, or 10) in craps.
A bet on a specific number (4, 5, 6, 8, 9, or 10) being rolled before a 7. Each number has a different payout ratio reflecting its probability of being rolled. Remains active until the number or a 7 is rolled.
- payout_ratios
9 to 5 on (4, 10), 7 to 5 on (5, 9), and 7 to 6 on (6, 8).
- Type:
Stores the place bet payouts
- losing_numbers: list[int] = [7]
Losing numbers for the bet
- number
The placed number, which determines payout ratio
- payout_ratio
Payout ratio for the bet
- winning_numbers
Winning numbers for the bet
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Buy(number: int, amount: SupportsFloat)
Bases:
_SimpleBetTrue-odds bet on 4/5/6/8/9/10 that charges vig per table policy.
Vig (commission) may be taken on the win or upfront based on
vig_paid_on_win.- true_odds
- losing_numbers: list[int] = [7]
Losing numbers for the bet
- number
- payout_ratio
Payout ratio for the bet
- winning_numbers
Base amount that determines true-odds payouts.
- get_result(table: Table) BetResult
Core bet logic that determines the result.
Wins are based on having dice total in the winning numbers (which may depend on the table), which will pay the payout_ratio times the bet amount plus the original bet amount back. Losses happen when dice total is in the losing numbers, which result in a loss of the original bet amount. Otherwise the bet stays on the table.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Lay(number: int, amount: SupportsFloat)
Bases:
_SimpleBetTrue-odds bet against 4/5/6/8/9/10, paying if 7 arrives first.
Commission may be taken on the win or upfront based on
vig_paid_on_win. Note that the vig is taken on the amount won, not the bet amount, since this is typically done in a casino (e.g. Laying the 4 for $40, which pays $20, would have a $1 vig).- true_odds
- winning_numbers: list[int] = [7]
Winning numbers for the bet
- number
- payout_ratio
Payout ratio for the bet
- losing_numbers
Base amount risked against the box number.
- get_result(table: Table) BetResult
Core bet logic that determines the result.
Wins are based on having dice total in the winning numbers (which may depend on the table), which will pay the payout_ratio times the bet amount plus the original bet amount back. Losses happen when dice total is in the losing numbers, which result in a loss of the original bet amount. Otherwise the bet stays on the table.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Field(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetField bet in craps.
A one-roll bet that wins if the next roll is 2, 3, 4, 9, 10, 11, or 12. Loses if 5, 6, 7, or 8 are rolled. Offers variable payouts for specific numbers as defined in the table settings (
TableSettings(), “field_payouts”:, which default to 2 to 1 for (2, 12) and 1 to 1 otherwise.- winning_numbers = [2, 3, 4, 9, 10, 11, 12]
Field wins on 2, 3, 4, 9, 10, 11, or 12
- losing_numbers = [5, 6, 7, 8]
Field loses on 5, 6, 7, or 8
- get_payout_ratio(table: Table) float
Returns the payout ratio (X to 1) based on table settings (
TableSettings(), “field_payouts”:
- class crapssim.bet.CAndE(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetCraps and Eleven (C & E) bet in craps.
A one-roll bet that wins if the next roll is 2, 3, 11, or 12. Offers different payout ratios for different winning numbers: - 3 to 1 for 2, 3, and 12 - 7 to 1 for 11 Loses on all other numbers.
- winning_numbers: list[int] = [2, 3, 11, 12]
Winning numbers are (2, 3, 11, 12).
- losing_numbers: list[int]
Losing numbers are anything besides (2, 3, 11, 12).
- class crapssim.bet.Any7(amount: SupportsFloat)
Bases:
_SimpleBetAny 7 bet (also known as Big Red) in craps.
A one-roll bet that wins only if the next roll is 7. Offers a 4 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [7]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except 7.
- payout_ratio: int = 4
Payout ratio for the bet
- class crapssim.bet.Two(amount: SupportsFloat)
Bases:
_SimpleBetTwo (Snake Eyes) bet in craps.
A one-roll bet that wins only if the next roll is 2. Offers a 30 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [2]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except 2.
- payout_ratio: int = 30
Payout ratio for the bet
- class crapssim.bet.Three(amount: SupportsFloat)
Bases:
_SimpleBetThree bet in craps.
A one-roll bet that wins only if the next roll is 3. Offers a 15 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [3]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except 3.
- payout_ratio: int = 15
Payout ratio for the bet
- class crapssim.bet.Yo(amount: SupportsFloat)
Bases:
_SimpleBetYo (Eleven) bet in craps.
A one-roll bet that wins only if the next roll is 11. Offers a 15 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [11]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except 11.
- payout_ratio: int = 15
Payout ratio for the bet
- class crapssim.bet.Boxcars(amount: SupportsFloat)
Bases:
_SimpleBetBoxcars (Midnight) bet in craps.
A one-roll bet that wins only if the next roll is 12. Offers a 30 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [12]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except 12.
- payout_ratio: int = 30
Payout ratio for the bet
- class crapssim.bet.AnyCraps(amount: SupportsFloat)
Bases:
_SimpleBetAny Craps bet in craps.
A one-roll bet that wins if the next roll is 2, 3, or 12. Offers a 7 to 1 payout and loses on all other numbers.
- winning_numbers: list[int] = [2, 3, 12]
Winning numbers for the bet
- losing_numbers: list[int]
Losing number is anything except (2, 3, 12).
- payout_ratio: int = 7
Payout ratio for the bet
- class crapssim.bet.Horn(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetOne-roll bet split across 2, 3, 11, and 12; loses on all other totals.
- winning_numbers: list[int] = [2, 3, 11, 12]
- losing_numbers: list[int]
- get_payout_ratio(table: Table) float
Payout ratios expressed as ‘to 1’, aligned with single bets and adjusting for the full bet amount returned on a win: - 2/12: (30 - 3) / 4 = 6.75 - 3/11: (15 - 3) / 4 = 3.0
- __repr__() str
- class crapssim.bet.World(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBetOne-roll bet covering Horn numbers plus 7; pays break-even on 7.
- winning_numbers: list[int] = [2, 3, 7, 11, 12]
- losing_numbers: list[int]
- get_payout_ratio(table: Table) float
Payout ratios expressed as ‘to 1’, consistent with simulator and adjusting for the full bet amount returned on a win:: - 2/12: (30 - 4) / 5 = 5.2 - 3/11: (15 - 4) / 5 = 2.2 - 7: (4 - 4) / 5 = 0.0
- __repr__() str
- class crapssim.bet.Big6(amount: SupportsFloat)
Bases:
_SimpleBetEven-money bet that wins on 6 before 7.
- winning_numbers: list[int] = [6]
Winning numbers for the bet
- losing_numbers: list[int] = [7]
Losing numbers for the bet
- payout_ratio: float = 1.0
Payout ratio for the bet
- number = 6
- __repr__() str
- class crapssim.bet.Big8(amount: SupportsFloat)
Bases:
_SimpleBetEven-money bet that wins on 8 before 7.
- winning_numbers: list[int] = [8]
Winning numbers for the bet
- losing_numbers: list[int] = [7]
Losing numbers for the bet
- payout_ratio: float = 1.0
Payout ratio for the bet
- number = 8
- __repr__() str
- class crapssim.bet.HardWay(number: int, amount: SupportsFloat)
Bases:
BetHard Way bet (on 4, 6, 8, or 10) in craps.
A bet on rolling a specific even number (4, 6, 8, or 10) with both dice showing the same value (e.g., two 2s for a hard 4). Wins if the number is rolled in a “hard” way before either a 7 or the number is rolled in a “soft” way.
- payout_ratios
7 to 1 for hard 4 or 10, 9 to 1 for hard 6 or 8.
- Type:
Payout ratios vary
- number: int
- payout_ratio: float
- get_result(table: Table) BetResult
Core bet logic that determines the result.
This determines the ultimate amount and whether the bet needs to be removed, which is indicated with a BetResult object.
- property winning_result: tuple[int, int]
Returns the dice result that wins, e.g. (2, 2) for Hard 4.
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Hop(result: tuple[int, int], amount: SupportsFloat)
Bases:
BetHop bet in craps.
A one-roll bet on a specific dice combination. Can be an “easy” hop (different values on each die) or a “hard” hop (same value on both dice).
Payouts differ based on whether the hop is easy or hard, and are set in the table settings (
TableSettings(), “hop_payouts”) - Easy hop: standard payout (default 15 to 1) - Hard hop: higher payout (default 30 to 1)- result: tuple[int, int]
- get_result(table: Table) BetResult
Core bet logic that determines the result.
This determines the ultimate amount and whether the bet needs to be removed, which is indicated with a BetResult object.
- property is_easy: bool
- property winning_results: list[tuple[int, int]]
- property _placed_key: Hashable
- __repr__() str
- __str__() str
- class crapssim.bet.Fire(amount: float)
Bases:
BetFire bet in craps.
A progressive bet that tracks points made during a shooter’s turn. Wins with increasing payouts based on the number of unique point numbers made before a 7 is rolled.
Payout escalates as more points are made: - Specific payout ratios depend on table settings (
TableSettings(), “fire_payouts”), default is 24 to 1 for four points, 249 to 1 for five points, and 999 to 1 for all six points. - Automatically ends when all 6 points are made or a 7 is rolled while the point is On.- points_made: set[int]
- ended: bool = False
- get_result(table: Table) BetResult
Core bet logic that determines the result.
This determines the ultimate amount and whether the bet needs to be removed, which is indicated with a BetResult object.
- class crapssim.bet.All(amount: float)
Bases:
_ATSBetAll bet (part of All/Tall/Small bets) in craps.
Wins when 2, 3, 4, 5, 6, 8, 9, 10, 11, and 12 all roll before a 7 rolls. Loses immediately if a 7 is rolled (including come-out sevens). Payout ratios are determined by the
TableSettings()([“ATS_payouts”][“all”]), which defaults to 150 to 1.- type: str = 'all'
- numbers: list[int] = [2, 3, 4, 5, 6, 8, 9, 10, 11, 12]
- class crapssim.bet.Tall(amount: float)
Bases:
_ATSBetTall bet (part of All/Tall/Small bets) in craps.
Wins when 8, 9, 10, 11, and 12 all roll before a 7 rolls. Loses immediately if a 7 is rolled (including come-out sevens). Payout ratios are determined by the
TableSettings()([“ATS_payouts”][“tall”]), which defaults to 30 to 1.- type: str = 'tall'
- numbers: list[int] = [8, 9, 10, 11, 12]
- class crapssim.bet.Small(amount: float)
Bases:
_ATSBetSmall bet (part of All/Tall/Small bets) in craps.
Wins when 2, 3, 4, 5, and 6 all roll before a 7 rolls. Loses immediately if a 7 is rolled (including come-out sevens). Payout ratios are determined by the
TableSettings()([“ATS_payouts”][“small”]), which defaults to 30.- type: str = 'small'
- numbers: list[int] = [2, 3, 4, 5, 6]