Cover photo

Understanding the Math Behind Crash

Why Crash?

Unlike traditional casino games like slots or card games, or even newer games like Plinko, Crash offers a thrilling opportunity for players to win big payouts - up to 500x and even as high as 20,000x their bet amount.

Crash stands out in the gambling world due to its distinctive probability distribution. Most casino games have fixed odds, predictable patterns, or capped multipliers. In contrast, Crash introduces a dynamic scale of potential outcomes, where the adrenaline-pumping possibility of hitting extraordinary multipliers exists every single round. This mechanism often causes players to intentionally wait for a certain multiplier before cashing out. Cashing out too early is another situation players might find themselves in, where they might watch the multiplier go up to a 1000x when they cashed out at 2x, causing them to FOMO in even harder the next game as they believe they can keep chasing a certain outcome. This is what makes Crash unique.

Probability Density Function and Randomization Algorithm

The thrill of the Crash game comes from its unpredictable nature and the potential for significant multipliers. Our algorithm is based on an exponential decay model, which determines the point at which the game "crashes" or ends. This model is characterized by the following key aspects:

1. Initial Randomness

When a new game starts, a random number is generated. This randomness value is used as a seed in the calculation of the crash point.

post image

2. Concatenation of Randomness and House Secret

The crash point is a critical aspect of the game as it determines when the multiplier stops increasing. The crash point is calculated using a combination of randomness and secret hashes to ensure fairness and unpredictability. The crash point is determined by combining the randomness with a secret provided by the house:

post image

The randomness is converted to a string and concatenated with the house_secret (a string provided by the house and known only to the house until the game ends). This combined string is then hashed using the SHA-3 256-bit hash function.

3. Crash Point Determination

The hash value is then used to determine the crash point:

post image

The `parse_hex` function converts the hash (a hexadecimal value) to a numerical value. If the numerical value modulo 33 equals 0, the crash point is set to 0, indicating an immediate crash. Otherwise, the first 7 bytes of the hash are used to calculate the crash point. This value is converted to a 64-bit unsigned integer and processed through the formula:

res=100×252value252valueres = \frac{100 \times 2^{52} - \text{value}}{2^{52} - \text{value}}

This formula ensures a crash point greater than 1. If the result is exactly 1, it is adjusted to 0 to avoid ambiguity.

4. Distribution of Crash Points

The probability distribution of crash points in the game of Crash is what sets it apart from other casino games. This distribution is continuous and heavily skewed, following an exponential decay pattern. Here's a breakdown of this unique distribution:

  1. Frequent Low Multipliers: The majority of crash points occur at lower multipliers (1-2x). This creates a sense of regular, smaller wins that keep players engaged.

  2. Decreasing Probability for Higher Multipliers: As the multiplier increases, the probability of the crash increases exponentially. This means that while it's common to see multipliers like 2x or 3x, it becomes increasingly rare to witness multipliers of 10x, 100x, or higher.

  3. Rare but Possible Extreme Events: What makes Crash truly exciting is the mathematical possibility of extremely high multipliers. Events like a 500x or even a 20,000x multiplier are rare but not impossible. These rare events create FOMO, with many users prematurely cashing out at 10x, only to watch the multiplier soar to 500x. This often leaves them regretting their decision and wishing they had the will to hold on longer.

  4. Continuous Nature: Unlike many gambling games with discrete outcomes, Crash offers a continuous distribution of possible results. This smooth curve of probabilities allows for a wide range of strategies and risk preferences among players.

  5. Long-Tail Distribution: The distribution exhibits a "long tail," meaning that while extremely high multipliers are rare, they do occur occasionally, contributing significantly to the game's expected value and player excitement.

Exponential Distribution
Exponential Distribution

This graph illustrates the probability distribution of crash points. Notice how the probability drops sharply as the multiplier increases, but never quite reaches zero, allowing for those rare, extremely high multiplier events. It's this unique probability distribution that allows Crash to offer the potential for massive wins while still maintaining a predictable house edge over the long run.

Betting and Cashing Out

Players place bets and can cash out at any multiplier before the crash point.

1. Placing Bets

When a player places a bet:

post image

The player's address and bet amount are recorded. The `cash_out` option is initially set to none.

2. Cashing Out

Players can choose to cash out before the crash point:

post image

The player's cash-out multiplier is recorded. Players cannot cash out more than once per game.

Winnings Calculation

After the crash point is revealed, winnings are calculated based on whether the player cashed out before the crash.

1. Determining Winnings

Winnings are calculated using the player's bet amount and cash-out multiplier:

post image

If the player did not cash out, winnings are 0. If the player cashed out before the crash point, winnings are calculated as:

winnings=bet amount×cash out multiplier100winnings = \text{bet amount} \times \frac{\text{cash out multiplier}}{100}

House Edge Calculation

To calculate the house edge, let's break down the expected value (EV) of a player's bet. We'll consider the probability distribution of crash points and the resulting payouts.

Immediate Crash Probability

From the code, we see that the crash point is immediately set to 0 (resulting in a loss) if the hash value modulo 33 equals 0:

post image

This means the probability of an immediate crash is:

P(immediate crash)=1333.03P(\text{immediate crash}) = \frac{1}{33} \approx 3.03%

Expected Value (EV)

The EV of a bet can be calculated as:

EV=i=1NP(Mi)×Payout(Mi)\text{EV} = \sum_{i=1}^{N} P(M_i) \times \text{Payout}(M_i)

where P(Mi)P(M_i) is the probability of the multiplier MiM_i and Payout(Mi)\text{Payout}(M_i) is the expected payout if the crash occurs at MiM_i.

Given that players typically aim to cash out at a multiplier that offers them a safe return while accounting for the risk of crashing, the payout can be simplified to:

Payout(Mi)=Mi×Bet Amount\text{Payout}(M_i) = M_i \times \text{Bet Amount}

However, since the probability P(Mi)P(M_i) decreases as MiM_i​ increases, we need to factor this into our calculation.

Simplified Calculation

Assuming the average cash out multiplier MM (a safe multiplier players typically aim for), we can estimate the EV with consideration of an immediate crash:

EV(1133)×M×Bet Amount\text{EV} \approx \left(1 - \frac{1}{33}\right) \times M \times \text{Bet Amount}

The house edge is the difference between the player's original bet and the EV:

House Edge=Bet AmountEV\text{House Edge} = \text{Bet Amount} - \text{EV}

House Edge=Bet Amount(1(1133)×M)\text{House Edge} = \text{Bet Amount} \left( 1 - \left( 1 - \frac{1}{33} \right) \times M \right)

House Edge=Bet Amount(133×M)\text{House Edge} = \text{Bet Amount} \left( \frac{1}{33} \times M \right)

Example Calculation

If the average multiplier MM that players cash out at is 1.5x (assuming players aim for a 50% return on their bet before cashing out), the house edge would be:

EV=(1133)×1.5×Bet Amount\text{EV} = \left( 1 - \frac{1}{33} \right) \times 1.5 \times \text{Bet Amount}

EV=(3233)×1.5×Bet Amount\text{EV} = \left( \frac{32}{33} \right) \times 1.5 \times \text{Bet Amount}

EV1.4545×Bet Amount\text{EV} \approx 1.4545 \times \text{Bet Amount}

House Edge=Bet Amount1.4545×Bet Amount\text{House Edge} = \text{Bet Amount} - 1.4545 \times \text{Bet Amount}

House Edge=Bet Amount(11.4545)\text{House Edge} = \text{Bet Amount} \left( 1 - 1.4545 \right)

House Edge=Bet Amount×0.04554.55\text{House Edge} = \text{Bet Amount} \times 0.0455 \approx 4.55%

Simulation Results and Analysis

To understand the implications of the unique game design of Crash, we need to go beyond mathematical modeling and examine the real world behavior of players. This is why we conducted simulations based on the data from the Zion Bets testnet. Our goal was to quantify profitability for gamblers as well as the house (a.k.a Liquidity Providers). We did this by:

  1. Analyzing player behavior patterns from the testnet data, including betting amounts, cash out points, and game frequency.

  2. Extrapolating this data to create a larger, more diverse sample size that maintains the characteristics of real player behavior:

    • 70% of players cash out between 1.1x and 2x multiplier.

    • 25% of players cash out between 2x and 5x multiplier.

    • 5% of players aim for high multipliers, cashing out between 5x and 20x.

  3. Implementing a Python simulation that incorporates these behavioral patterns and the core game mechanics, including the 3.03% chance of immediate crash.

  4. Running thousands of simulated games with parameters calibrated to match observed player behaviors, allowing us to explore a wide range of scenarios.

  5. Calculating key metrics such as Return to Player (RTP) percentage, house edge, average profit per game, and potential Annual Percentage Yield (APY) for liquidity providers.

  6. Visualizing the results to provide clear insights into the game's performance over time and under various conditions.

These simulations help us answer common questions that both players and potential investors might have:

  • Is the Crash game actually profitable for the house in the long run?

  • How often do players win?

  • What happens if a player hits a massive multiplier? Can the house cover big wins?

  • As an investor, what kind of returns can I expect if I provide liquidity to the game?

  • How long does it typically take for the house to become profitable?

  • Can skilled players beat the house edge in Crash?

Return to Player (RTP) and House Edge

Worst case (lower bound) house edge = 3.03%
Worst case (lower bound) house edge = 3.03%

The Return to Player (RTP) percentage is a crucial metric in gambling games, representing the proportion of wagers that players can expect to receive back over time. Our simulation results show a theoretical RTP of 94.78%, with a corresponding house edge of 5.22%.

The RTP is calculated as follows:

\text{RTP} = \text{100%} - \text{House Edge}

This high RTP of 94.78% ensures that players have a fair chance of winning, while the house maintains a slight edge to ensure long term profitability. It's important to note that this is a theoretical value based on the average cash out multiplier observed in our simulations. Actual results may vary in the short term due to individual player strategies.

House Profit per Game

post image

This histogram shows the distribution of house profits across individual games. The x-axis represents profit (or loss) per game, with the zero point in the middle. Bars to the left of zero indicate games where the house paid out to winners, while bars to the right represent profitable games for the house.

Key observations:

  1. The red dotted line shows an average profit of $160.88 per game.

  2. There's a wide distribution of outcomes, reflecting the game's volatility.

  3. Despite frequent payouts to players (losses for the house), the overall volume of profitable games ensures a positive average profit.

This distribution aligns with the theoretical model of Crash, demonstrating how the house can maintain profitability while still offering winning opportunities to players.

Long Term Profitability for Liquidity Providers

post image

This dual-axis line chart visualizes of the house’s long term profitability and potential returns for liquidity providers.

The green line represents the Annual Percentage Yield (APY) for liquidity providers, while the red line shows the cumulative profit over time. Key insights from this graph include:

  1. Initial Volatility: In the early stages, the house may experience some losses, reflected in the negative cumulative profit and fluctuating APY.

  2. Trend Towards Profitability: As more games are played and the law of large numbers comes into play, the cumulative profit line trends upward, demonstrating the house's long term advantage.

  3. Stabilizing APY: While the APY line is volatile early on, it tends to stabilize over time. In this simulation, it settles around 41.60%, indicating attractive potential returns for liquidity providers.

  4. Volume Impact: The chart suggests that increased game and betting volume is directly correlated to more predictable returns.

  5. Liquidity: The volatility in house P&L shows the importance of sufficient liquidity to absorb short term fluctuations.

Conclusion

Our comprehensive analysis of the Crash game, powered by simulation and real world data from the Zion Bets testnet, reveals a gaming model that balances player satisfaction with house profitability. The unique probability distribution of Crash, together with its high RTP and potential for large payout multipliers, makes it an attractive option for both players and investors in the GambleFi sector.

The simulation code used to generate these insights is available on our GitHub:

https://github.com/SeamMoney/zionbets/blob/main/simulations.py

As we prepare for mainnet launch on the Aptos blockchain, we are committed to providing ongoing data analysis and listening to player feedback. The Crash game represents not just an exciting gambling experience, but a new frontier in onchain casino games.

https://www.zion.bet/