init_hp = 200000
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:
hp2 -= (1-a2[2])*(s1[1]+a2[1])
if hp2 <= 0:
return True
next_attack1 += s1[2]
if next_attack2 == tick:
hp1 -= (1-a1[2])*(s2[1]+a1[1])
if hp1 <= 0:
return False
next_attack2 += s2[2]
tick += 1
def main():
combos = []
for s in swords:
for a in armors:
combos.append([s, a, 0])
while combos:
for c1 in combos:
for c2 in combos:
if fight(c1[0], c1[1], c2[0], c2[1]):
c1[2] += 1
else:
c2[2] += 1
print ""
print "Pass " + str(17-len(combos)) + ":"
combos = sorted(combos, key=lambda combo: combo[2])
for c in combos:
print str(c[2]) + ": " + c[0][0] + "/" + c[1][0]
c[2] = 0
del combos[0]
if __name__ == '__main__':
main()