Initial commit

This commit is contained in:
Abhorrent_Anger 2025-04-22 10:54:04 +03:00
parent 0543f7871d
commit ad19a7268f

148
main.py Normal file
View File

@ -0,0 +1,148 @@
from enum import Enum
import datetime
import random
import math
# Use cent values instead of token floats
# Note: Could be set as launch args
BET_GREEN = 0
BET_RED = 30
BET_BLACK = 30
BET_BAIT = 10
MULTIPLIER_RED = 2.1
MULTIPLIER_BLACK = 2.1
MULTIPLIER_GREEN = 14.7
MULTIPLIER_BAIT = 7.0
balance = 0
loss_streak = 0
win_streak = 0
biggest_loss_streak = 0
biggest_win_streak = 0
is_last_roll_win = False
rolls = 0
real_time = 0
total_bet = 0
average_net = 0
class Hit(Enum):
GREEN = 0
BLACK = 1
RED = 2
BAIT = 3
@classmethod # Refer to https://onecompiler.com/javascript/42qq3ryft for logic
def roll_result(cls, index):
if index == 0:
return [cls.GREEN]
if index == 1:
return [cls.BAIT, cls.RED]
if index <= 7:
return [cls.RED]
if index == 8:
return [cls.BAIT, cls.BLACK]
return [cls.BLACK]
@classmethod
def get_multiplier(cls, hit):
return globals()["MULTIPLIER_" + hit.name]
def run_simulation():
payouts = Hit.roll_result(roll())
difference = pay_out(payouts)
update_statistics(difference)
print_statistics()
def roll():
return random.randint(0, 14) # Modulo of 15 rolls over at 15
def pay_out(payout_enum_array):
global total_bet
income = 0
for payout in payout_enum_array:
multiplier = Hit.get_multiplier(payout)
bet_amount = globals()["BET_" + payout.name]
income += calculate_payout(bet_amount, multiplier)
return income - total_bet
def calculate_payout(bet, multiplier):
return math.floor(bet * multiplier)
def update_statistics(difference):
global balance
balance += difference
update_roll_statistics()
update_streak_statistics(difference)
update_average_statistic(difference)
def update_roll_statistics():
global rolls, real_time
rolls += 1
real_time = datetime.timedelta(seconds=rolls * 15)
def update_streak_statistics(difference):
global loss_streak, win_streak, biggest_loss_streak, biggest_win_streak
if difference < 0: # Loss
loss_streak += difference
abs_loss_streak = abs(loss_streak)
if abs_loss_streak > biggest_loss_streak:
biggest_loss_streak = abs_loss_streak
win_streak = 0
else: # Win
win_streak += difference
if win_streak > biggest_win_streak:
biggest_win_streak = win_streak
loss_streak = 0
def update_average_statistic(difference):
global rolls, average_net, total_bet
net = difference + total_bet
average_net = average_net + ((net - average_net) / rolls)
def print_statistics():
global total_bet, rolls, real_time, balance, biggest_loss_streak, biggest_win_streak
message = (
"\rTotal bet: "
+ str(total_bet / 100.0)
+ "; Average net: "
+ str(int(average_net) / 100.0)
+ "; Loss streak: "
+ str(biggest_loss_streak / 100.0)
+ "; Win streak: "
+ str(biggest_win_streak / 100.0)
+ "; Rolls: "
+ str(rolls)
+ "; Real time: "
+ str(real_time).ljust(18)
+ "; Balance: "
+ str(balance / 100.0)
)
print(message, end="")
def set_total_bet():
global total_bet
total_bet = BET_GREEN + BET_BLACK + BET_RED + BET_BAIT
while True:
if BET_GREEN and BET_RED and BET_BLACK:
print("Bet not allowed (arbitrary site restriction)!")
quit()
set_total_bet()
try:
run_simulation()
except KeyboardInterrupt:
quit()