Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding:utf-8
- import random
- class Fighter(object):
- def __init__(self, strength):
- self.strength = strength
- f1 = Fighter(10)
- f2 = Fighter(12)
- def fight(fighter1, fighter2):
- """
- This function inputs two fighters and pseudo-randomly picks a winner,
- with the stronger fighter more likely to win, etc.
- """
- L = []
- for x in random.range(1, fighter1.strength):
- L.append(fighter1)
- for y in range(1, fighter2.strength):
- L.append(fighter2)
- return random.choice(L)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement