Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, operator
- def main():
- bestof = int(raw_input("(odd number) - Best of :"))
- if not bestof % 2: raise Exception, "Make that shit an odd number"
- print "Playing best of %d" % bestof
- calls = {
- # key's value is what key beats
- "rock": "scissors",
- "paper": "rock",
- "scissors": "paper"
- }
- points = {
- "You": 0,
- "Computer": 0
- }
- for turn in range(1, bestof + 1):
- print "Turn %d/%d" % (turn, bestof)
- yourCall = raw_input("Make a call (rock, paper, scissors) :").lower()
- if yourCall not in calls: raise Exception, "Fuck you, play the game right."
- themCall = random.choice(calls.keys())
- print "You: %s" % yourCall
- print "Computer: %s" % themCall
- if yourCall == themCall:
- print "Tie! No points gained."
- elif themCall == calls[yourCall]:
- print "You win that turn! Point to You!"
- points["You"] += 1
- else:
- print "Computer wins that turn! Point to Computer!"
- points["Computer"] += 1
- if len(list(set(points.values()))) == 1:
- print "Draw! NOBODY WINS"
- else:
- print "!!!!Winner is %s!!!!" % max(points.iteritems(), key=operator.itemgetter(1))[0]
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement