Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import readline
- import math
- sh = {"a": "apple", "b": "banana", "r": "berry", "c": "cherry", "j": "jackpot", "w": "watermelon"}
- fruits = ["apple", "banana", "berry", "cherry", "jackpot", "watermelon"]
- #Gathered from the 5-slots, so multiply by 5 to get original values.
- #apples might be 500
- #bananas might be 375
- #no idea on jackpot
- rewards = {"cherry": 10, "watermelon": 25, "berry": 40, "apple": 100, "banana": 75, "jackpot": 500}
- def inits():
- global firsts
- global seconds
- global thirds
- global totals
- global wins
- global win_total
- global losses
- global history
- global win_cash
- firsts = {}
- seconds = {}
- thirds = {}
- totals = {}
- wins = {}
- win_total = 0
- losses = 0
- win_cash = 0
- history = []
- for fruit in fruits:
- firsts[fruit] = 0
- seconds[fruit] = 0
- thirds[fruit] = 0
- totals[fruit] = 0
- wins[fruit] = 0
- inits()
- def inc_totals(results):
- r_first = results[0:1].lower()
- r_second = results[1:2].lower()
- r_third = results[2:3].lower()
- firsts[sh[r_first]] += 1
- seconds[sh[r_second]] += 1
- thirds[sh[r_third]] += 1
- totals[sh[r_first]] += 1
- totals[sh[r_second]] += 1
- totals[sh[r_third]] += 1
- def win_check(results):
- first_char = results[0:1].lower()
- if results.lower() == first_char*3:
- return sh[first_char]
- else:
- return False
- def parse_results(results):
- global losses
- global win_total
- global wins
- global win_cash
- inc_totals(results)
- win_result = win_check(results)
- if win_result:
- print("WIN: " + win_result)
- win_cash += rewards[win_result]
- wins[win_result] += 1
- win_total += 1
- else:
- losses += 1
- history.append(results)
- def calc_percent(num, decimals=1):
- num *= (10**(2 + decimals))
- num = round(num)
- num = num / (10 ** decimals)
- return num
- def display_stats():
- win_rate = calc_percent(win_total / losses)
- total_fruits = (losses + win_total) * 3
- games_played = (losses + win_total)
- fruit_rates = {}
- print("STATS")
- for fruit in fruits:
- fruit_rates[fruit] = calc_percent(totals[fruit] / total_fruits)
- print(fruit + " rate: " + str(fruit_rates[fruit]) + "%")
- print("Win Rate: " + str(win_rate) + "%")
- print("Profit: " + str(round((win_cash / games_played) * 1000)/1000) + "x")
- print("PREDICTIONS")
- fruit_win_rates = {}
- weighted_returns = {}
- loss_rate = 1
- for fruit in fruits:
- fruit_win_rates[fruit] = (totals[fruit] / total_fruits)**3
- weighted_returns[fruit] = fruit_win_rates[fruit] * (100 * (rewards[fruit] -1) )
- loss_rate -= fruit_win_rates[fruit]
- print(fruit + " win rate: " + str(calc_percent(fruit_win_rates[fruit],3)) + "%")
- weighted_returns["bust"] = (loss_rate * -100)
- weighted_sum = 0
- for weight in weighted_returns:
- weighted_sum += weighted_returns[weight]
- multiplied_returns = 1
- multiplied_returns += (weighted_sum / 100)
- print("Expected Win Rate: " + str(calc_percent(1 - loss_rate)) + "%")
- print("Expected Return: " + str(round(multiplied_returns*1000)/1000) + "x")
- print("Data is from " + str(len(history)) + " rolls.")
- def display_history():
- print(str(history))
- def import_history(hist):
- global history
- inits()
- hist = eval(hist)
- for roll in hist:
- parse_results(roll)
- print("Type 'stats' for stats!")
- print("Type 'history' for history!")
- print("Type 'import []' to import!")
- while True:
- results = input()
- if results == "stats":
- display_stats()
- elif results == "history":
- display_history()
- elif results[0:7] == "import ":
- import_history(results[7:])
- else:
- parse_results(results)
Advertisement
Add Comment
Please, Sign In to add comment