Advertisement
Adepht

Shadowverse Collection simulation

May 5th, 2017
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.65 KB | None | 0 0
  1. # Usage - scriptname amount_of_runs dust_animated_first
  2. # Notes - probability of fully animated packs is unknown, so this simulation to ignores it
  3.  
  4. import sys
  5. import random
  6.  
  7. vials = [[10, 30], [50, 120], [250, 600], [1000, 2500]]  # dis value for normal/animated
  8. vials_cost = [50, 200, 800, 3500]                        # craft value
  9. animated_chance = 0.08                                   # no info on full animated packs
  10.  
  11. expansion_size = [32, 32, 24, 16]                        # TotG
  12. #expansion_size = [40, 32, 24, 9]                        # RoB
  13. #expansion_size = [46, 31, 23, 9]                        # DE
  14. #expansion_size = [126, 99, 69, 24]                      # Standard
  15. opened_cards = [[[0, 0] for i in range(expansion_size[0])], [[0, 0] for i in range(expansion_size[1])], [[0, 0] for i in range(expansion_size[2])], [[0, 0] for i in range(expansion_size[3])]]
  16.  
  17. dust_gained = 0
  18. dust_needed = 3 * (vials_cost[0] * expansion_size[0] + vials_cost[1] * expansion_size[1] + vials_cost[2] * expansion_size[2] + vials_cost[3] * expansion_size[3])
  19. print("Total vial cost of the expansion: " + str(dust_needed))
  20. dusted = [[0, 0], [0, 0], [0, 0], [0, 0]]
  21.  
  22. def add_card(rarity, dust): # dust is order of dusting - 1 for dusting animated cards first, 0 for keeping them                    
  23.     global opened_cards
  24.     global dusted
  25.     global dust_gained
  26.     global dust_needed
  27.     anim = 1 if random.random() < 0.08 else 0 #animated check
  28.     card = random.randint(0, expansion_size[rarity] - 1)
  29.     count = opened_cards[rarity][card][0] + opened_cards[rarity][card][1]
  30.     if count < 3:
  31.         opened_cards[rarity][card][anim] += 1
  32.         dust_needed -= vials_cost[rarity]
  33.     else:
  34.         if (opened_cards[rarity][card][dust] > 0):
  35.             dust_gained += vials[rarity][dust]
  36.             opened_cards[rarity][card][dust] -= 1
  37.             dusted[rarity][dust] += 1
  38.             opened_cards[rarity][card][anim] += 1
  39.         else:
  40.             dust_gained += vials[rarity][anim]
  41.             dusted[rarity][anim] += 1
  42.    
  43.  
  44. def open_pack(dust = 1): # dust is order of dusting - 1 for dusting animated cards first, 0 for keeping them
  45.     for x in range(8):
  46.         p = random.random()
  47.         if p < 0.675 :  # 67.5% bronze
  48.             add_card(0, dust) if x != 7 else add_card(1, dust) # last card is silver+
  49.             continue
  50.         if p < 0.925 :  # 25% silver
  51.             add_card(1, dust)
  52.             continue
  53.         if p < 0.985 :  # 6% gold
  54.             add_card(2, dust)
  55.             continue
  56.         add_card(3, dust)      # 1.5% legendary
  57.  
  58. def check_completition(): #
  59.     global dust_needed
  60.     global dust_gained
  61.     if dust_needed < dust_gained:
  62.         return True
  63.     else:
  64.         return False
  65.  
  66. def zero_cards_opened(): #reset everything between runs
  67.     global opened_cards
  68.     global dusted
  69.     global dust_gained
  70.     global dust_needed
  71.  
  72.     opened_cards = [[[0, 0] for i in range(expansion_size[0])], [[0, 0] for i in range(expansion_size[1])], [[0, 0] for i in range(expansion_size[2])], [[0, 0] for i in range(expansion_size[3])]]
  73.     dust_gained = 0
  74.     dust_needed = 3 * (vials_cost[0] * expansion_size[0] + vials_cost[1] * expansion_size[1] + vials_cost[2] * expansion_size[2] + vials_cost[3] * expansion_size[3])
  75.     dusted = [[0, 0], [0, 0], [0, 0], [0, 0]]
  76.        
  77. def main():
  78.     global opened_cards
  79.     global dusted
  80.     global dust_gained
  81.     global dust_needed
  82.     argv = sys.argv
  83.     if (len(argv) == 1): # add 1 try if not specified
  84.         argv.append(1)
  85.     if (len(argv) < 3):  # dust animateds
  86.         argv.append(1)
  87.     random.seed()
  88.     total_packs_opened = 0
  89.     for x in range(int(argv[1])):
  90.         packs_opened = 0
  91.         zero_cards_opened()
  92.         while(not check_completition()):
  93.             open_pack(int(argv[2]))
  94.             packs_opened += 1
  95.         total_packs_opened += packs_opened
  96. #        print(packs_opened)
  97. #    print('Vials to complete: ' + str(dust_needed))
  98. #    print('Vials gained: ' + str(dust_gained))
  99. #    print('Dusted Bronze cards: ' + str(dusted[0][0]) + ', Animated: ' + str(dusted[0][1]))
  100. #    print('Dusted Silver cards: ' + str(dusted[1][0]) + ', Animated: ' + str(dusted[1][1]))
  101. #    print('Dusted Gold cards: ' + str(dusted[2][0]) + ', Animated: ' + str(dusted[2][1]))
  102. #    print('Dusted Legendary cards: ' + str(dusted[3][0]) + ', Animated: ' + str(dusted[3][1]))
  103.     print("Opened packs on average: " + str(float(total_packs_opened)/int(argv[1])))
  104. #    print(opened_cards)
  105. #    check_completition(0, True)
  106.    
  107.        
  108. if __name__ == '__main__':
  109.     main()
  110.    
  111.    
  112. #Results:
  113. # TotG: 267 packs
  114. # RoB: 175 packs
  115. # DE: 173 packs
  116. # Standard: 482 packs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement