import random from collections import defaultdict history = [] last_seen_4 = 0 last_seen_5 = 0 last_roll_not_feature = True def get5star(): #if the last 5 star is not promo, get promo global last_roll_not_feature if last_roll_not_feature: last_roll_not_feature = False return "featured" if random.random() < 0.5: last_roll_not_feature = False return "featured" else: last_roll_not_feature = True return "non-featured" def gacha(): global last_seen_5 global last_seen_4 GACHA = random.random() if GACHA <= 0.006 or last_seen_5 == 89: last_seen_5 = 0 last_seen_4 = 0 return get5star() elif GACHA <= 0.057 or last_seen_4 == 9: last_seen_4 = 0 last_seen_5 += 1 return "some 4 star character" 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 < 7): PULL = gacha() total_pull += 1 history += [PULL] if PULL == "featured": featured_count += 1 history_total += [total_pull] print("Average pulls required for C6 featured 5 star" ,sum(history_total)/len(history_total))