Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Rock Paper Scissors
- import random
- #1 corresponds to Rock, 2 corresponds to Paper, 3 corresponds to Scissors.
- choices=[1,2,3]
- player_pt=0
- bot_pt=0
- player_choice=0
- bot_choice=0
- #Function for initiating bot_choice and getting player_choice.
- def initialize():
- global bot_choice
- bot_choice=random.choice(choices)
- print "\n1.Rock\n2.Paper\n3.Scissors"
- global player_choice
- player_choice=int(raw_input("Enter the number of your choice:"))
- while player_choice not in range(1,4):
- player_choice=raw_input("\nInvalid input!\nEnter the number alone.\n1.Rock\n2.Paper\n3.Scissors\nEnter your choice again:")
- #Function for evaluation.
- def evaluate():
- global player_pt
- global bot_pt
- if player_choice==bot_choice:
- print "\nThat was a tie!\nLets try again! Bet I'll win this time!"
- elif player_choice==1 and bot_choice==2:
- bot_pt+=1
- print "\nI beat you this time!I chose Paper!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- elif player_choice==1 and bot_choice==3:
- player_pt+=1
- print "\nYou got lucky!You won this time!I chose Scissors!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- elif player_choice==2 and bot_choice==1:
- player_pt+=1
- print "\nYou got lucky!You won this time!I chose Rock!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- elif player_choice==2 and bot_choice==3:
- bot_pt+=1
- print "\nI beat you this time!I chose Scissors!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- elif player_choice==3 and bot_choice==1:
- bot_pt+=1
- print "\nI beat you this time!I chose Rock!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- elif player_choice==3 and bot_choice==2:
- player_pt+=1
- print "\nYou got lucky!You won this time!I chose Paper!"
- print player_name,":",player_pt,"\nBot:",bot_pt
- print "Hi there! I'm Rock-Paper-Scissors bot!"
- player_name=raw_input("What's your name?")
- print "Ready to play with me",player_name,"?! One who scores 10 points first wins!!"
- while player_pt<10 and bot_pt<10:
- initialize()
- evaluate()
- if player_pt==10:
- print "\nKudos",player_name,"! You won!"
- elif bot_pt==10:
- print "\nI won!Better luck next time",player_name,"!"
- raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement