Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def simulateBattle(troop1, troop2, inc=0, inc2=0, nsim=100):
- res = range(nsim)
- for i in range(nsim):
- p1 = troop1; p2 = troop2; t = 1
- while p1 < p2 and p1 > 0:
- if t > 1:
- p1 = p1 + inc
- p2 = p2 + inc2
- else:
- t += 1
- tp1 = p1
- p1 = p1 - sum([random.random() < 0.6 for _ in range(p2)])
- p2 = p2 - sum([random.random() < 0.7 for _ in range(tp1)])
- res[i] = p1 <= 0 and p2 > 0
- return sum(res)/(nsim*1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement