Facebook
From kettletoro, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 336
  1. import random
  2. from collections import defaultdict
  3.  
  4.  
  5. history = []
  6. last_seen_4 = 0
  7. last_seen_5 = 0
  8. last_roll_not_feature = True
  9.  
  10. def get5star():
  11.     #if the last 5 star is not promo, get promo
  12.     global last_roll_not_feature
  13.     if last_roll_not_feature:
  14.         last_roll_not_feature = False
  15.         return "featured"
  16.  
  17.     if random.random() < 0.5:
  18.         last_roll_not_feature = False
  19.         return "featured"
  20.  
  21.     else:
  22.         last_roll_not_feature = True
  23.         return "non-featured"
  24.  
  25.  
  26.  
  27. def gacha():
  28.     global last_seen_5
  29.     global last_seen_4
  30.     GACHA = random.random()
  31.  
  32.     if GACHA <= 0.006 or last_seen_5 == 89:
  33.         last_seen_5 = 0
  34.         last_seen_4 = 0
  35.         return get5star()
  36.    
  37.     elif GACHA <= 0.057 or last_seen_4 == 9:
  38.         last_seen_4 = 0
  39.         last_seen_5 += 1
  40.         return "some 4 star character"
  41.     else:
  42.         last_seen_5 +=1
  43.         last_seen_4 +=1
  44.         return "nice 3 star sword"
  45.  
  46. history_5_star = defaultdict(int)
  47. history_total = []
  48.  
  49. for i in range(10000):
  50.     history = []
  51.     total_pull = 0
  52.     featured_count = 0
  53.     while(featured_count < 1):
  54.         PULL = gacha()
  55.         total_pull += 1
  56.         history += [PULL]
  57.         if PULL == "featured":
  58.             featured_count += 1
  59.     history_total += [total_pull]
  60.  
  61.  
  62.  
  63.  
  64. print("Average pulls required for C0 featured 5 star" ,sum(history_total)/len(history_total))