Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. # Simple Rock Paper Scissor Game
  2. # First player to five wins
  3. # Player selects his and the computer selection is random
  4.  
  5. import random
  6.  
  7. hand_list = ('Rock','Paper','Scissors')
  8. win_list = [['Rock', 'Scissors'], ['Paper', 'Rock'], ['Scissors', 'Paper']]
  9.  
  10. def play_game():
  11. count = 0
  12. p_wins = 0
  13. c_wins = 0
  14. while p_wins < 4 or c_wins < 4:
  15. # Player Selection
  16. p = input("\nWhat is your selection? \n 1:Rock \n 2:Paper \n 3:Scissors")
  17. p = int(p)- 1
  18. while p < 0 or p > 2:
  19. print("Try Again")
  20. p = input("\n What is your selection? \n 1:Rock \n 2:Paper \n 3:Scissors")
  21. p = int(p)- 1
  22. p_selection = hand_list[p]
  23. # Computer Selection
  24. i = random.randint(0,2)
  25. c_selection = hand_list[i]
  26.  
  27. # Display Results
  28. print("Player chooses: {} \nComputer chooses: {}".format(p_selection,c_selection))
  29. played = [p_selection, c_selection]
  30. if p_selection == c_selection:
  31. print("\nTie Match")
  32. print("Player:{} Computer: {}".format(p_wins,c_wins))
  33.  
  34. elif played in win_list:
  35. print ("\nPlayer wins this game")
  36. c_wins
  37. p_wins +=1
  38. print("Player:{} Computer: {}".format(p_wins,c_wins))
  39.  
  40. else:
  41. print("\nComputer wins this game ")
  42. p_wins
  43. c_wins += 1
  44. print("Player:{} Computer: {}".format(p_wins,c_wins))
  45. if p_wins > 4:
  46. print("Player Wins!{} to {}".format(p_wins,c_wins))
  47. break
  48. if c_wins >4:
  49. print("Computer Wins! Better Luck next time")
  50. break
  51.  
  52.  
  53. print("Welcome to Rock Paper Scissor!")
  54. print("First One to Five Wins!")
  55. play_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement