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. |
|
Place bet (on 4, 5, 6, 8, 9, or 10) in craps. |
|
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. |
|
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.
- property won: bool
Returns True if the bet won (positive amount).
- 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.ABC
A 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.
- abstract 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)
- class crapssim.bet._WinningLosingNumbersBet(amount: SupportsFloat)
Bases:
Bet
,abc.ABC
A 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.
- abstract get_winning_numbers(table: Table) list[int]
Returns the winnings numbers, based on table features
- class crapssim.bet._SimpleBet(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBet
,abc.ABC
A 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:
_WinningLosingNumbersBet
Pass 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:
_WinningLosingNumbersBet
Come 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
- class crapssim.bet.DontPass(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBet
Don’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.
Note that a push will keep the bet active and not result in any change to bankroll.
- 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:
_WinningLosingNumbersBet
Don’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
- class crapssim.bet.Odds(base_type: Type[PassLine | DontPass | Come | DontCome], number: int, amount: float)
Bases:
_WinningLosingNumbersBet
Odds 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
- property light_side: bool
- property dark_side: bool
- 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.
- property _placed_key: Hashable
- __repr__()
- class crapssim.bet.Place(number: int, amount: SupportsFloat)
Bases:
_SimpleBet
Place 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
- class crapssim.bet.Field(amount: SupportsFloat)
Bases:
_WinningLosingNumbersBet
Field 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:
_WinningLosingNumbersBet
Craps 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:
_SimpleBet
Any 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:
_SimpleBet
Two (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:
_SimpleBet
Three 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:
_SimpleBet
Yo (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:
_SimpleBet
Boxcars (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:
_SimpleBet
Any 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.HardWay(number: int, amount: SupportsFloat)
Bases:
Bet
Hard 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
- class crapssim.bet.Hop(result: tuple[int, int], amount: SupportsFloat)
Bases:
Bet
Hop 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
- class crapssim.bet.Fire(amount: float)
Bases:
Bet
Fire 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:
_ATSBet
All 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:
_ATSBet
Tall 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:
_ATSBet
Small 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]