Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import random
- # Standard game result multipliers
- STD_DOUBLE = 2
- STD_GREEN = 14
- # Enhanced "0%-edge" game result multipliers (for $MONK bets)
- HOUSE_EDGE = 0
- ZERO_EDGE_DOUBLE = (1 - HOUSE_EDGE) / (7 / 15) # 2.14
- ZERO_EDGE_GREEN = (1 - HOUSE_EDGE) / (1 / 15) # 15
- print(f"Enhanced 0%-edge 2x red/black multiplier: {ZERO_EDGE_DOUBLE:.2f}x")
- print(f"Enhanced 0%-edge 14x green multiplier: {ZERO_EDGE_GREEN:.2f}x")
- def generate_balance_history_graph(std_balance_history, zero_edge_balance_history):
- plt.figure(figsize=(10, 5))
- plt.plot(std_balance_history, marker='.', color='green')
- plt.plot(zero_edge_balance_history, marker='|', color='blue')
- plt.title('Roulette user balance history')
- plt.xlabel('Bet #')
- plt.ylabel('Balance')
- plt.show()
- def plot_frequency_bar_chart(frequency_array):
- plt.figure(figsize=(10, 5))
- roulette_results = range(len(frequency_array))
- plt.bar(roulette_results, frequency_array, color='blue')
- plt.title('Game result distribution')
- plt.xlabel('Roulette numbers')
- plt.ylabel('Frequency')
- plt.xticks(roulette_results)
- plt.show()
- # red: 1-7, black: 8-14, green: 15
- def gen_result(result_idx):
- if result_idx >= 1 and result_idx <= 7:
- return STD_DOUBLE, ZERO_EDGE_DOUBLE, 'red', result_idx
- if result_idx >= 8 and result_idx <= 14:
- return STD_DOUBLE, ZERO_EDGE_DOUBLE, 'black', result_idx
- if result_idx == 15:
- return STD_GREEN, ZERO_EDGE_GREEN, 'green', result_idx
- NUM_SIMS = 10000
- START_BALANCE = 100
- BET_AMOUNT = 1
- def simulate_bets(results, is_theoretical = False):
- result_distribution = np.zeros(15)
- std_balance_history = np.zeros(NUM_SIMS)
- zero_edge_balance_history = np.zeros(NUM_SIMS)
- std_balance = START_BALANCE
- zero_edge_balance = START_BALANCE
- std_total_wagered = 0
- zero_edge_total_wagered = 0
- default_bet_color = 'black' # (only for theoretical scenario)
- for i in range(len(results)):
- multiplier, zero_edge_multiplier, color, idx = results[i]
- result_distribution[idx - 1] += 1
- std_balance_history[i] = std_balance
- zero_edge_balance_history[i] = zero_edge_balance
- random_color = ['red', 'green', 'black'][random.randint(0, 2)]
- user_bet_color = random_color if not is_theoretical else default_bet_color
- bet_won = user_bet_color == color
- if bet_won:
- if (std_balance > 0):
- std_balance += (BET_AMOUNT * multiplier) - BET_AMOUNT
- std_total_wagered += BET_AMOUNT
- if (zero_edge_balance > 0):
- zero_edge_balance += (BET_AMOUNT * zero_edge_multiplier) - BET_AMOUNT
- zero_edge_total_wagered += BET_AMOUNT
- else:
- if (std_balance > 0):
- std_balance -= BET_AMOUNT
- std_total_wagered += BET_AMOUNT
- if (zero_edge_balance > 0):
- zero_edge_balance -= BET_AMOUNT
- zero_edge_total_wagered += BET_AMOUNT
- generate_balance_history_graph(std_balance_history, zero_edge_balance_history)
- # plot_frequency_bar_chart(result_distribution)
- print('Standard total wagered:', zero_edge_total_wagered)
- print('Zero edge total wagered:', zero_edge_total_wagered)
- # User bets on a random color; game outcome is random
- def simulated():
- results = list(map(lambda x: gen_result(x), np.random.randint(1, 15 + 1, NUM_SIMS)))
- simulate_bets(results)
- # User bets on constant color; game outcomes matches theoretical expected distribution
- def theoretical():
- results = [gen_result((i % 15) + 1) for i in range(NUM_SIMS)]
- simulate_bets(results, True)
- theoretical()
- simulated()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement