Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import copy
- from pprint import pprint
- # Ungoro Cards
- #Tier 1: 3 epic 1 legend
- #Tier 2: 7 epic 5 legend
- #Playable: 10 epic 11 legend
- NUM_COMMONS = 49
- NUM_RARES = 36
- NUM_EPICS = 27
- NUM_LEGENDARIES = 23
- META_LEGENDARIES = 1
- META_EPICS = 3
- dust_value = {'Common': 5,
- 'Rare': 20,
- 'Epic': 100,
- 'Legendary': 400,
- 'Golden Common': 50,
- 'Golden Rare': 100,
- 'Golden Epic': 400,
- 'Golden Legendary': 1600}
- card_collection_template = {'Common': [0 for i in range(NUM_COMMONS)],
- 'Rare': [0 for i in range(NUM_RARES)],
- 'Epic': [0 for i in range(NUM_EPICS)],
- 'Legendary': [0 for i in range(NUM_LEGENDARIES)],
- 'Golden Common': [0 for i in range(NUM_COMMONS)],
- 'Golden Rare': [0 for i in range(NUM_RARES)],
- 'Golden Epic': [0 for i in range(NUM_EPICS)],
- 'Golden Legendary': [0 for i in range(NUM_LEGENDARIES)]}
- class Card:
- def __init__(self, rarity, card_id):
- self.rarity = rarity
- self.card_id = card_id
- def create_pack():
- pack = []
- for i in range(5):
- r = random.random()
- if r < .701362:
- card = Card('Common', random.randint(0, NUM_COMMONS-1))
- elif r - .701362 < .209809:
- card = Card('Rare', random.randint(0, NUM_RARES - 1))
- elif r - .911172 < .043960:
- card = Card('Epic', random.randint(0, NUM_EPICS - 1))
- elif r - .955132 < .011262:
- card = Card('Legendary', random.randint(0, NUM_LEGENDARIES - 1))
- elif r - .966394 < .014714:
- card = Card('Golden Common', random.randint(0, NUM_COMMONS - 1))
- elif r - .981108 < .015441:
- card = Card('Golden Rare', random.randint(0, NUM_RARES - 1))
- elif r - .996549 < .002361:
- card = Card('Golden Epic', random.randint(0, NUM_EPICS - 1))
- elif r - .998910 < .001090:
- card = Card('Golden Legendary', random.randint(0, NUM_LEGENDARIES - 1))
- pack.append(card)
- return pack
- def calc_remaining_dust_custom(card_collection):
- remaining_dust = 0
- for card_type in ['Common', 'Rare', 'Epic', 'Legendary']:
- for x, cards in enumerate(card_collection[card_type]):
- if card_type == 'Common':
- if cards == 0:
- remaining_dust += 80
- elif cards == 1:
- remaining_dust += 40
- if card_type == 'Rare':
- if cards == 0:
- remaining_dust += 200
- elif cards == 1:
- remaining_dust += 100
- if card_type == 'Epic':
- if cards == 0:
- remaining_dust += 800
- elif cards == 1:
- remaining_dust += 400
- if x == META_EPICS and card_type == 'Epic':
- break
- if card_type == 'Legendary':
- if cards == 0:
- remaining_dust += 1600
- if x == META_LEGENDARIES and card_type == 'Legendary':
- break
- return remaining_dust
- def calc_duplicate_dust(card_collection):
- collection_dust = 0
- for card_type in ['Golden Common', 'Golden Rare', 'Golden Epic', 'Golden Legendary']:
- for cards in card_collection[card_type]:
- collection_dust += (cards) * dust_value[card_type]
- for card_type in ['Common', 'Rare', 'Epic', 'Legendary']:
- for x, cards in enumerate(card_collection[card_type]):
- if card_type == 'Common':
- if cards > 2:
- collection_dust += (cards - 2) * 5
- if card_type == 'Rare':
- if cards > 2:
- collection_dust += (cards - 2) * 20
- if x >= META_EPICS and card_type == 'Epic':
- if cards > 0:
- collection_dust += cards * 100
- if x < META_EPICS and card_type == 'Epic':
- if cards > 2:
- collection_dust += (cards - 2) * 100
- if x >= META_LEGENDARIES and card_type == 'Legendary':
- if cards > 0:
- collection_dust += cards * 400
- if x < META_LEGENDARIES and card_type == 'Legendary':
- if cards > 1:
- collection_dust += (cards - 1) * 400
- return collection_dust
- def calc_collection_value(card_collection):
- collection_dust = 0
- for card_type in ['Common', 'Rare', 'Epic', 'Legendary']:
- for x, cards in enumerate(card_collection[card_type]):
- if card_type == 'Common':
- if cards > 2:
- collection_dust += 2 * 40
- elif card_type == 1:
- collection_dust += 40
- if card_type == 'Rare':
- if cards > 2:
- collection_dust += 2 * 100
- elif card_type == 1:
- collection_dust += 200
- if x < META_EPICS and card_type == 'Epic':
- if cards > 2:
- collection_dust += 2 * 400
- elif card_type == 1:
- collection_dust += 400
- if x == META_EPICS and card_type == 'Epic':
- break
- if x < META_LEGENDARIES and card_type == 'Legendary':
- if cards > 1:
- collection_dust += 1600
- if x == META_LEGENDARIES and card_type == 'Legendary':
- break
- return collection_dust
- def count_commons(card_collection):
- completion = 0
- for cards in card_collection['Common']:
- if cards > 2:
- completion += 2
- elif cards == 1:
- completion += 1
- return completion
- def no_dupes(card_collection):
- dupes=0
- zeroindex=[]
- for i in range(len(card_collection['Legendary'])):
- if card_collection['Legendary'][i]==0:
- zeroindex.append(i)
- random.shuffle(zeroindex)
- for i in range(len(card_collection['Legendary'])):
- if card_collection['Legendary'][i]>1:
- dupes = dupes + 1
- card_collection['Legendary'][i] = 1
- card_collection['Legendary'][zeroindex.pop()]=1
- return card_collection
- def main():
- tries = 500
- packs_needed = []
- pack_dust = []
- total_value = []
- common_array = []
- for i in range(tries):
- collection_incomplete = True
- card_collection = copy.deepcopy(card_collection_template)
- pack_counter = 0
- while collection_incomplete:
- pack_counter += 1
- contains_legendary = False
- pack = create_pack()
- for card in pack:
- card_collection[card.rarity][card.card_id] += 1
- card_collection = no_dupes(card_collection)
- collection_value = calc_collection_value(card_collection)
- duplicate_dust = calc_duplicate_dust(card_collection)
- remaining_dust = calc_remaining_dust_custom(card_collection)
- commons = count_commons(card_collection)
- if duplicate_dust >= remaining_dust:
- collection_incomplete = False
- common_array.append(commons)
- total_value.append((duplicate_dust + collection_value) / pack_counter)
- pack_dust.append(duplicate_dust / pack_counter)
- packs_needed.append(pack_counter)
- print('Stats Based on ' + str(tries) + ' tries')
- print('For a collection comprising ' + str(META_EPICS) + ' epics, and ' + str(META_LEGENDARIES) + ' legendaries')
- print('Average Packs required: ' + str(sum(packs_needed) / tries))
- print('Average Dust per pack: ' + str(sum(pack_dust) / tries))
- print('Average Value per pack: ' + str(sum(total_value) / tries))
- print('Average Common completion: ' + str(sum(common_array) / tries))
- pprint(card_collection['Legendary'])
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment