Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # coding:utf-8
  3. import random
  4.  
  5. class Fighter(object):
  6. def __init__(self, strength):
  7. self.strength = strength
  8.  
  9. f1 = Fighter(10)
  10. f2 = Fighter(12)
  11.  
  12. def fight(fighter1, fighter2):
  13. """
  14. This function inputs two fighters and pseudo-randomly picks a winner,
  15. with the stronger fighter more likely to win, etc.
  16. """
  17. L = []
  18. for x in random.range(1, fighter1.strength):
  19. L.append(fighter1)
  20. for y in range(1, fighter2.strength):
  21. L.append(fighter2)
  22. return random.choice(L)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement