import random
init_hp = 80000
ticks_per_minute = 3600
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()