Saturday, December 16, 2023

wager simulation

import random


# Define parameters

starting_wager = 0.03

multiplier = 7.0714

win_chance = 0.14

win_increase = 0.8

consecutive_losses_reset = 2

num_simulations = 1000

num_games_per_simulation = 1000


# Desired win streak lengths to track

desired_win_streaks = [2, 3, 4, 5]


# Function to simulate a single game

def simulate_game():

  current_wager = starting_wager

  consecutive_losses = 0

  consecutive_wins = 0

  win_streak_counts = {streak: 0 for streak in desired_win_streaks} # Initialize streak counters

  for _ in range(num_games_per_simulation):

    win = random.random() < win_chance

    if win:

      consecutive_wins += 1

      consecutive_losses = 0

      for streak in desired_win_streaks: # Update counters for desired streaks

        if consecutive_wins >= streak:

          win_streak_counts[streak] += 1

    else:

      consecutive_wins = 0

      consecutive_losses += 1

      if consecutive_losses == consecutive_losses_reset:

        current_wager = starting_wager

        consecutive_losses = 0

  return current_wager, win_streak_counts


# Run simulations and collect results

total_win_streaks = {streak: 0 for streak in desired_win_streaks}

for _ in range(num_simulations):

  _, win_streak_counts = simulate_game()

  for streak, count in win_streak_counts.items():

    total_win_streaks[streak] += count


# Analyze and print results

average_win_streak = sum(total_win_streaks.values()) / num_simulations

print(f"Average win streak needed: {average_win_streak:.2f}")


# Calculate and print success rates for different win streak lengths

success_rates = {}

for i in range(1, max(desired_win_streaks) + 1):

  success_rates[i] = sum(w >= i for w in total_win_streaks.values()) / len(total_win_streaks)

print("--- Success Rates by Win Streak Length ---")

for streak, rate in success_rates.items():

  print(f"{streak} wins: {rate:.2%}")


# Print specific win streak occurrences

print("--- Consecutive Win Occurrences ---")

for streak, count in total_w

in_streaks.items():

  print(f"{streak} wins: {count}")


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home