Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def computer_random_number():
  5. random_number = random.randint(1, 3)
  6. return move_options.get(random_number)
  7.  
  8.  
  9. def moves_input():
  10. player_input = input("Rock, Paper or Scissors: ").lower()
  11. if player_input not in move_options.values():
  12. print("Are you crazy? That's an invalid move..")
  13. player_input = input("CHOOSE ROCK, PAPER OR SCISSORS' YOU IMBECILE: ")
  14. return player_input
  15.  
  16.  
  17. def game():
  18. if player_move == comp_move:
  19. print("tie")
  20. elif (player_move, comp_move) in winning_moves_index:
  21. print("Well Done!")
  22. else:
  23. print("computer wins")
  24. print(f'\n Player Chose: {player_move}, Computer Chose: {comp_move}\n')
  25. print(f'Computer Score: {computer_score}, \nPlayer Score: {player_score}')
  26.  
  27.  
  28. move_options = {1: "rock", 2: "paper", 3: "scissors"}
  29. winning_moves_index = ("rock", "scissors"), ("paper", "rock"), ("scissors", "paper")
  30.  
  31. player_score = 0
  32. computer_score = 0
  33. max_score = 5
  34.  
  35. while True:
  36. comp_move = computer_random_number()
  37. player_move = moves_input()
  38. moves_index = (player_move, comp_move)
  39. game()
  40. if player_move == "rock" and comp_move == "scissors":
  41. player_score = player_score + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement