Now computing casting probability over turns
This commit is contained in:
parent
e7a14dafc1
commit
21c40b275a
1 changed files with 23 additions and 3 deletions
26
analyze.py
26
analyze.py
|
@ -39,6 +39,24 @@ def mana_curve(deck):
|
|||
for c in costs:
|
||||
data[c] += 1
|
||||
return data
|
||||
|
||||
def rampup(deck, type=None):
|
||||
print '{0} Rampup'.format((type if type else 'spell').title())
|
||||
print '-' * 80
|
||||
land = [c for c in deck if 'land' in c.type.split(' ')]
|
||||
cards = [c for c in deck if c.cost.converted() > 0]
|
||||
if type:
|
||||
cards = [c for c in cards if type in c.type.split(' ')]
|
||||
avgCost = sum([c.cost.converted() for c in cards]) / float(len(cards))
|
||||
maxCost = sorted([c.cost.converted() for c in cards]).pop()
|
||||
print 'Average {0} cost: {1:.3f}'.format(type if type else 'spell', avgCost)
|
||||
avgCost = int(round(avgCost))
|
||||
for turn in range(avgCost, maxCost + 1):
|
||||
castable = [c for c in cards if c.cost.converted() <= turn]
|
||||
pm = 1 - draw_probability(len(land), deck, avgCost, turn)
|
||||
pc = 1 - draw_probability(len(castable), deck, 1, turn, avgCost)
|
||||
p = 1 - pm - pc
|
||||
print 'Probability of drawing {0} mana in {1} turns with a castable {3}: {2:.3f}'.format(avgCost, turn, p * 100, type if type else 'spell')
|
||||
def types(deck):
|
||||
return {
|
||||
'Lands': len([c for c in deck if 'land' in c.type.split(' ')]),
|
||||
|
@ -102,6 +120,8 @@ if __name__ == '__main__':
|
|||
graph(types(deck), '\nCard Types')
|
||||
graph(colors(deck), '\nColors')
|
||||
graph(rarities(deck), '\nRarities')
|
||||
|
||||
print '\nProbability of drawing 4 mana in 4 turns: {0:.3f}'.format(100 * draw_probability(len([c for c in deck if 'land' in c.type.split(' ')]), deck, 4, 4))
|
||||
print 'Probability of drawing a creature costing 4 or fewer mana in 4 turns: {0:.3f}'.format(100 * draw_probability(len([c for c in deck if 'creature' in c.type.split(' ') and c.cost.converted() <= 4]), deck, 1, 4, 4))
|
||||
|
||||
print
|
||||
rampup(deck)
|
||||
print
|
||||
rampup(deck, 'creature');
|
||||
|
|
Loading…
Reference in a new issue