import random from collections import defaultdict history = [] last_seen_4 = 0 last_seen_5 = 0 last_roll_not_feature = True missed = 0 featured = ['Weapon A','Weapon B'] def get5star(): global last_roll_not_feature global missed #epitomised path if missed == 2: missed = 0 return "Weapon A" if last_roll_not_feature: last_roll_not_feature = False featured_weapon = random.choice(featured) if featured_weapon == "Weapon A": missed = 0 return "Weapon A" else: missed += 1 return "Weapon B" if random.random() <= 0.75: last_roll_not_feature = False featured_weapon = random.choice(featured) if featured_weapon == "Weapon A": missed = 0 return "Weapon A" else: missed += 1 return "Weapon B" else: last_roll_not_feature = True missed += 1 return "Non-featured" def gacha(): global last_seen_5 global last_seen_4 GACHA = random.random() if GACHA <= 0.007 or last_seen_5 == 80: last_seen_5 = 0 last_seen_4 = 0 return get5star() elif GACHA <= 0.067 or last_seen_4 == 9: last_seen_4 = 0 last_seen_5 += 1 return "some 4 star thing" else: last_seen_5 +=1 last_seen_4 +=1 return "nice 3 star sword" history_5_star = defaultdict(int) history_total = [] for i in range(10000): history = [] total_pull = 0 featured_count = 0 while(featured_count < 5): PULL = gacha() total_pull += 1 history += [PULL] if PULL == 'Weapon A': featured_count += 1 history_total += [total_pull] print("Average pulls required for R5 featured 5 star weapon" ,sum(history_total)/len(history_total))