1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python

import random

init_hp = 80000
ticks_per_minute = 3600 # LCM of speed values
swords = [
    ('blue',   100, ticks_per_minute/80),
    ('red',    80,  ticks_per_minute/100),
    ('yellow', 150, ticks_per_minute/50),
    ('green',  50,  ticks_per_minute/180),
]        
armors = [
    ('blue',   -12, 10),
    ('red',     -8, 15),
    ('yellow', -20,  0),
    ('green',    0, 24),
]

"Fight two tuples, returns True if player 1 wins."
def fight(s1, a1, s2, a2):
    hp1 = init_hp
    hp2 = init_hp
    next_attack1 = 0
    next_attack2 = 0
    tick = 0
    while True:
        if next_attack1 == tick:
            if random.randint(1, 100) > a2[2]:
                hp2 -= s1[1] + a2[1]
                if hp2 <= 0:
                    return True
            next_attack1 += s1[2]
        if next_attack2 == tick:
            if random.randint(1, 100) > a1[2]:
                hp1 -= s2[1] + a1[1]
                if hp1 <= 0:
                    return False
            next_attack2 += s2[2]
        tick += 1

def main():    
    random.seed()
    combos = {}
    for s in swords:
        for a in armors:
            combos[(s, a)] = 0
    for i in range(0, 30):
        for c1 in combos:
            for c2 in combos:
                if fight(c1[0], c1[1], c2[0], c2[1]):
                    combos[c1] += 1
                else:
                    combos[c2] += 1
    for c in combos:
        print str(combos[c]) + ": " + c[0][0] + "/" + c[1][0]

if __name__ == '__main__':
    main()