Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. import random
  2. def main():
  3. playerName=introduction()
  4. humplayer=hum_player()
  5. compchoice=com_player()
  6. tieScore = 0
  7. humScore=0
  8. comScore=0
  9. humplayer=input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): ")
  10. while humplayer != -1:
  11. compchoice=com_player()
  12. result= evaluate_Game(humplayer,compchoice,playerName)
  13. if result==0:
  14. print("It's a tie!")
  15. tieScore+=1
  16. elif result==1:
  17. comScore+=1
  18. else:
  19. humScore+=1
  20. humplayer=input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): ")
  21. print(statistics(playerName,humScore,comScore,tieScore))
  22.  
  23.  
  24.  
  25. def introduction():
  26. print("Welcome to the game of Rock, Paper, Scissors. You will be playing against the computer.")
  27. name= input("What is your name? ")
  28. print("Here are the rules", name+":")
  29. print(" If a player chooses Rock and the other chooses Scissors, Rock wins.")
  30. print(" If a player chooses Scissors and the other chooses Paper, Scissors wins.")
  31. print(" If a player chooses Paper and the other chooses Rock, Paper wins.")
  32. print(" If both players make the same choice, it's a tie.")
  33. print(" Enter -1 to quit the game ")
  34. return name
  35.  
  36. def hum_player():
  37. choice = int(input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): "))
  38. return choice
  39.  
  40. def com_player():
  41. random_Num = random.randint(0,2)
  42. return(random_Num)
  43.  
  44.  
  45.  
  46.  
  47. def evaluate_Game(humplayer,compchoice,playerName):
  48. a = "Rock"
  49. b="Paper"
  50. c="Scissors"
  51. if humplayer==0:
  52. if compchoice==0:
  53. return 0
  54. elif compchoice==1:
  55. print(playerName, "plays ",a," computer plays",b)
  56. print("Paper covers Rock, Computer wins!")
  57. return 1
  58. else:
  59. print(playerName, "plays",a,"computer plays", c)
  60. print("Rock crushes Scissors ,", playerName," wins!")
  61. return 2
  62. elif humplayer==1:
  63. if compchoice==0:
  64. print(name,"plays",b," computer plays", a)
  65. print("Paper covers Rock.", playerName,"wins!")
  66. return 2
  67. elif compchoice==1:
  68. print(playerName,"plays", b," computer plays" , b)
  69. print("It's a tie!")
  70. return 0
  71. else:
  72. print(playerName, "plays", b,"computer plays", c)
  73. print("Scissors cuts Paper. Computer wins!")
  74. return 1
  75. else:
  76. if compchoice==0:
  77. print(playerName, "plays", c," computer plays", a)
  78. print("Rock breaks Scissors. Computer wins!")
  79. return 1
  80. elif compchoice==1:
  81. print(playerName, "plays", c, " computer plays", b)
  82. print("Scissors cuts Paper." , playerName, "wins!")
  83. return 2
  84. else:
  85. print(playerName, "plays", c," computer plays", c)
  86. print("It's a tie!")
  87. return 0
  88.  
  89. def statistics(playerName,humScore,tieScore,comScore):
  90. print("There were", tieScore+comScore+humscore, "games:", playerName, "won", humScore, "games, the computer won", comScore, "games and there were", tieScore, "ties.")
  91.  
  92. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement