Facebook
From kettletoro, 2 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 257
  1. import random
  2. from collections import defaultdict
  3.  
  4.  
  5. history = []
  6. last_seen_4 = 0
  7. last_seen_5 = 0
  8.  
  9. def get4star():
  10.     if random.randint(1,43) == 43:
  11.         return "Amber"
  12.    
  13.     return "not Amber :("
  14.    
  15.    
  16.  
  17. def gacha():
  18.     global last_seen_5
  19.     global last_seen_4
  20.     GACHA = random.random()
  21.    
  22.     if GACHA <= 0.006 or last_seen_5 == 89:
  23.         last_seen_5 = 0
  24.         last_seen_4 = 0
  25.         return "some 5 star"
  26.    
  27.     elif GACHA <= 0.057 or last_seen_4 == 9:
  28.         last_seen_4 = 0
  29.         last_seen_5 += 1
  30.         return get4star()
  31.     else:
  32.         last_seen_5 +=1
  33.         last_seen_4 +=1
  34.         return "nice 3 star sword"
  35.  
  36. history_5_star = defaultdict(int)
  37. history_total = []
  38.  
  39. for i in range(10000):
  40.     history = []
  41.     total_pull = 0
  42.     featured_count = 0
  43.     while(featured_count < 6):
  44.         PULL = gacha()
  45.         total_pull += 1
  46.         history += [PULL]
  47.         if PULL == "Amber":
  48.             featured_count += 1
  49.     history_total += [total_pull]
  50.  
  51.  
  52. print("Average pulls required for C6 Amber" ,sum(history_total)/len(history_total))