Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random, randrange
- from collections import Counter
- # http://www.4shared.com/web/preview/pdf/mCdvUh9Wce
- # Chance Type Total Chance Dust
- # 70.00% common 100.00% 5
- # 21.51% rare 30.00% 20
- # 4.28% epic 8.49% 100
- # 1.47% golden common 4.21% 50
- # 1.27% golden rare 2.74% 100
- # 1.05% legendary 1.47% 400
- # 0.31% golden epic 0.42% 400
- # 0.11% golden legendary 0.11% 1600
- qualities = [ 'Common',
- 'Rare',
- 'Epic',
- 'Legendary',
- 'Golden Common',
- 'Golden Rare',
- 'Golden Epic',
- 'Golden Legendary' ]
- class HS_pack:
- def __init__(self, u_chance=.225, g_chance=.0225):
- self.qualities = [ 'Common',
- 'Rare',
- 'Epic',
- 'Legendary',
- 'Golden Common',
- 'Golden Rare',
- 'Golden Epic',
- 'Golden Legendary' ]
- self.dust_values = [5,20,100,400,50,100,400,1600]
- self.u_chance = u_chance
- self.g_chance = g_chance # stacking (e.g. common = 2.5% chance, rare = 5% chance, etc.)
- self.pack = []
- def get(self):
- for x in xrange(5):
- q = 0
- if x==4 and sum(self.pack)==0:
- q = 1
- while q < 3:
- roll = random()
- if roll < self.u_chance:
- q += 1
- else:
- break
- #gold roll
- g_roll = random()
- if g_roll < (q+1)*self.g_chance: q += 4
- self.pack.append(q)
- return self.pack
- def value(self):
- return sum([self.dust_values[x] for x in self.pack])
- def cards(self):
- return [self.qualities[x] for x in self.pack]
- cards = []
- total_dust = 0
- n = 100000
- for x in xrange(n):
- p = HS_pack()
- cards += p.get()
- total_dust += p.value()
- print 'Packs: {0:,}, Cards: {1:,}'.format(n,n*5)
- print '---'
- for q,x in Counter(cards).most_common():
- print '{0:16}{1:8,}{2:8.2%}'.format(qualities[q],cards.count(q),(x+0.0)/(n*5))
- print '---'
- print 'Average Dust:',total_dust/n
- # https://www.reddit.com/r/hearthstone/comments/2emnxl/drops_chances_rarity_by_11359_hearthstone_expert/
- # This strikes me as you not knowing how the card generation process actually works. Cards are not calculated as fixed percentages. The process is actually thus:
- # 1) A common in generated
- # 2) A "dice" rolled (aka a random number generated). If that roll is above a certain point, the card becomes rare.
- # 3) If the card is now rare, that dice is rolled again. If the roll is above a certain point, the card is now epic.
- # 4) If the card is now epic, roll the dice one more time for legendary.
- # The process surrounding becoming gold is unclear. Either it's a percentage chance at the end of the process, or there is an intermediate step throughout that can make a card gold, at which point it continues to be gold.
- # When it comes to the fact that a pack cannot have 5 commons, it is because the 5th card starts its life already in the rare state. Thus, the 5th card itself always has a higher chance of becoming epic or legendary, because its already rare. That is why a pack with 1 epic and 4 common is more common that a pack with 1 epic, 1 rare, and 3 commons.
- # FWIW, this is the same process Blizzard uses to generate drops in Diablo 2, 3, and WoW, which is why it is well known.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement