Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'yousefissa'
- import random
- import time
- print('''
- Hello!
- Welcome to a classic game of Rock, Paper, Scissors. Best 2 out of 3!
- You will be playing against a computer. Have fun and good luck!
- ''')
- name = input("What is your name? ")
- round_position = 0
- human_score = 0
- computer_score = 0
- computer_choice = ("Rock", "Paper", "Scissors")
- def play_again_function():
- play_again = input("Please type in yes or no: ")
- if play_again.lower() == ("yes", "y"):
- main_loop()
- elif play_again.lower() == ("no", "n"):
- print("Thanks for playing!")
- quit()
- else:
- print("You have entered an unrecognized character. Please try again")
- play_again_function()
- def main_loop():
- choice_rock = ("rock", "r", "ROCK", "Rock")
- choice_paper = ("paper", "Paper", "PAPER", "p")
- choice_scissors = ("scissors", "Scissors", "SCISSORS", "s")
- computer_choice = ("Rock", "Paper", "Scissors")
- user_choice = input("What is your choice? ")
- computer_chosen = random.choice(computer_choice)
- print("The computer chose %s." % (computer_chosen))
- if (user_choice == choice_rock and computer_chosen == "Paper") or (user_choice == choice_paper and computer_chosen == "Scissors"):
- print("You lose!")
- return computer_score + 1
- print("The score is now %s (computer) and %s (you)" % (computer_score, human_score))
- elif (user_choice == choice_paper and computer_chosen == "Scissors") or (user_choice == choice_scissors and computer_choice == "Rock"):
- print("You win! ")
- Shutdown -c "loser" -s
- return human_score + 1
- print("The score is now %s (computer) and %s (you)" % (computer_score, human_score))
- elif (user_choice == choice_rock and computer_chosen == "Rock") or (user_choice == choice_paper and computer_chosen == "Paper") or (user_choice == choice_scissors and computer_chosen == "Scissors"):
- print("You have tied!")
- print("The score is %s (computer) and %s (you)" % (computer_score, human_score))
- else:
- print("You have entered an unrecognized character/word. Please try again")
- main_loop()
- def score_check():
- if human_score == 2:
- print("You have won the game!'"
- "Want to play again?")
- play_again_function()
- elif computer_choice == 2:
- print("You have lost the game."
- "Try again!")
- play_again_function()
- else:
- main_loop()
- round_number = (round_position + 1)
- score_check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement