import random ai_choice = ["rock", "paper", "scissors"] failed_check = 0 def win_or_lose(player_move, ai_move, tie_score, player_score, ai_score): # calculating who's going to win if player_move == ai_move: print("You Tied") tie_score += 1 elif (player_move == "rock" and ai_move == "scissors" or player_move == "scissors" and ai_move == "paper" or player_move == "paper" and ai_move == "rock"): print("You Won!") player_score += 1 else: print("You Lose!") ai_score += 1 return player_score, tie_score, ai_score def getting_player_move(): while True: move_input = "Rock, Paper, Scissors, or exit? " player_move = input(move_input).lower().strip() if player_move not in ("rock", "paper", "scissors", "exit"): print("Invalid input. Choose Rock, Paper, or Scissors.") else: return player_move #game code name=input("what is your name? ") print("Welcome to Rock paper scissors",name) #this code checks if the user wants the rules or not while True: if failed_check == 3: print("you are being annoying") print("goodbye") exit() rules=input("Would you like to read the rules of the game?").lower() if rules in ("yes", "y"): print("---- rules ----") print("First you choose out of rock, paper, or scissors") print("At the same time, your opponent will pick a move.") print("The order of victory goes as follows:") print("Rock beats scissors, scissors beats paper and paper beats rock") print("If you pick the same move, you tie") print("That's all the rules, enjoy the game :).") elif rules in ("no","n"): print("Alright then if you really want") else: print("Please enter yes or no") failed_check += 1 continue while True: #seeing if the player wants to do a certain number of rounds or infinite choices = input("Would You like to play to a certain amount of rounds have been won or infinite rounds?(number of rounds or infinite) ").lower() if "infinite" in choices: player_score = 0 ai_score = 0 tie_score = 0 while True: #ai coding ai_move = random.choice(ai_choice) #player input player_move = getting_player_move() # exit code if player_move == "exit": print("The score is:", "Your wins", player_score, "| Ties", tie_score, "| AI wins", ai_score) print("Thanks for playing") break # announcing the moves print("rock paper scissors shoot") print("You:", player_move.capitalize()) print("AI:", ai_move.capitalize()) player_score, tie_score, ai_score = win_or_lose(player_move, ai_move, tie_score, player_score, ai_score) elif "round" in choices: while True: player_score = 0 ai_score = 0 tie_score = 0 rounds_number = input("How many rounds?") if not rounds_number.isdigit() or int(rounds_number) <= 0: print("Invalid input or choose a number greater than 0.") continue rounds = int(rounds_number) while player_score + tie_score + ai_score < rounds: #ai coding ai_move = random.choice(ai_choice) #player input player_move = getting_player_move() # exit code if player_move == "exit": print("The score is:", "Your wins", player_score, "| Ties", tie_score, "| AI wins", ai_score) print("Thanks for playing") break #announcing the moves print("rock paper scissors shoot") print("You:", player_move.capitalize()) print("AI:", ai_move.capitalize()) player_score, tie_score, ai_score = win_or_lose(player_move, ai_move, tie_score, player_score, ai_score) print("The score is:","Your wins",player_score,"Ties", tie_score,"AI wins", ai_score) break else: print("Invalid input choose rounds or infinite.")