Facebook
From kettletoro, 2 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 243
  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. missed = 0
  10. featured = ['Weapon A','Weapon B']
  11.  
  12. def get5star():
  13.     global last_roll_not_feature
  14.     global missed
  15.  
  16.     #epitomised path
  17.     if missed == 2:
  18.         missed = 0
  19.         return "Weapon A"
  20.  
  21.  
  22.     if last_roll_not_feature:
  23.         last_roll_not_feature = False
  24.  
  25.         featured_weapon = random.choice(featured)
  26.  
  27.         if featured_weapon == "Weapon A":
  28.             missed = 0
  29.             return "Weapon A"
  30.         else:
  31.             missed += 1
  32.             return "Weapon B"
  33.    
  34.    
  35.     if random.random() <= 0.75:
  36.         last_roll_not_feature = False
  37.         featured_weapon = random.choice(featured)
  38.  
  39.         if featured_weapon == "Weapon A":
  40.             missed = 0
  41.             return "Weapon A"
  42.         else:
  43.             missed += 1
  44.             return "Weapon B"
  45.  
  46.  
  47.     else:
  48.         last_roll_not_feature = True
  49.         missed += 1
  50.         return "Non-featured"
  51.  
  52.  
  53. def gacha():
  54.     global last_seen_5
  55.     global last_seen_4
  56.     GACHA = random.random()
  57.  
  58.     if GACHA <= 0.007 or last_seen_5 == 80:
  59.         last_seen_5 = 0
  60.         last_seen_4 = 0
  61.         return get5star()
  62.    
  63.     elif GACHA <= 0.067 or last_seen_4 == 9:
  64.         last_seen_4 = 0
  65.         last_seen_5 += 1
  66.         return "some 4 star character"
  67.     else:
  68.         last_seen_5 +=1
  69.         last_seen_4 +=1
  70.         return "nice 3 star sword"
  71.  
  72. history_5_star = defaultdict(int)
  73. history_total = []
  74.  
  75. for i in range(10000):
  76.     history = []
  77.     total_pull = 0
  78.     featured_count = 0
  79.     while(featured_count < 1):
  80.         PULL = gacha()
  81.         total_pull += 1
  82.         history += [PULL]
  83.         if PULL == 'Weapon A':
  84.             featured_count += 1
  85.     history_total += [total_pull]
  86.  
  87.  
  88.  
  89.  
  90. print("Average pulls required for R1 featured 5 star weapon" ,sum(history_total)/len(history_total))