In [ ]:
#!/usr/bin/python

from random import randint 
import random 
from time import sleep 
from os import system 

#These are for the game to work because the game needs toe Sleep Function, the OS System fuction is for the defuct Clear_Output, and the Random is for the Randint which is a random number which is used for a number of different things. The Sleep Fucnction is used but it is rare for me to use it because I only used it in a f ew places because of reasons
def playerinfo():    
    global userName 
    userName = input("Please input username")
    Menu()
    #Used earlier to work more properly within the code because it makes it easy to use at Menu, Endgame, and the game proper.

def clear_output(): 
    system("sis")
#This would normally be used for clearing the screen however this currently is defuct due to it not working.

aiWins = 0
playerWins = 0
ties = 0
aiName = "Mikaeli"
userName = ""
computerChoose = ""


#These are used for a bunch of things within the game, there are three rounds within the game and the AI is named "Mikaeli" with Ties, Player Wins, and AiWins all being tracted for stastical reasons and the player name is already listed so I can change it more easily later.

            
def RPC(): #This is the actual game, it works by referring to the Computer function, and also removing round one by one until 3/3 have been being reached this is because it will be limited and it also also makes sure there is a tie function, and then if it doesn't end up in a tie it checks which one you choose and then the AI and then if the AI chooses the looser you win and if they do anything else, they win, and to prevent them from choosing something that isn't a number or not a number between 0 - 2 it will fail you immediately. It also contains the endgame code because it use to not work so I decided it would be better to just do it internally in the code and because it just makes more sense.
    global Rounds
    global playerWins
    global aiWins
    Rounds = 3
    playerWins = 0
    aiWins = 0
    choices = ["ROCK","PAPER","SCISSORS"]
    computerChoose = choices[randint(0, 2)]
    
    
    hand = ["ROCK","PAPER","SCISSORS"]
    
    
    try:
        while True: 
            print("0. Rock")
            print("1. Paper")
            print("2. Scissors")
            
            userChoise = int(input("1. Rock. 2. Paper. 3. Scissors."))
            userChoise = hand[userChoise - 0]
            
            print("player chose {}".format(userChoise))
            print("{} chose {}".format(aiName, computerChoose))
            
            if userChoise == computerChoose:
                print("TIE")
                rounds = -1
                
                    
            elif userChoise == "ROCK": #From here to line 95 the codie is the internal logic for winning/lossing because I do not count tieing the game as winning  and 
                
                if computerChoose == "SCISSORS":
                    playerWins = +1
                    Rounds = -1
                    print("{} wins".format(userName))
                    
                    
                else: 
                    print("{} wins".format(aiName))
                    aiWins = +1
                    Rounds = -1
                    print("You have {} rounds left".format(Rounds))
                   
                    
               
            elif userChoise == "PAPER":              
                if computerChoose == "ROCK":
                    print("{} wins".format(userName))
                    playerWins = +1
                   
                    
                else: 
                    print("{} wins".format(aiName))
                    aiWins = +1
                    
                    
                
                    
            elif userChoise == "SCISSORS":
                if computerChoose == "PAPER":
                    print("{}wins".format(userName))
                    playerWins = +1
                    
                    
            if Rounds <= 0:
                print("Game ending. No more rounds.")
                input("Ending....")
                if aiWins > playerWins:
                    print("{} has won {} times, player has lost".format(aiName, aiWins))
                    print("Would you like to go again?")
                    print("Press '1' if you want to keep playing")
                    print("Press '2' if you want to quit")
        
                    userInput2 = input("Input code")
        
                    if userInput2 == "1":
                     rounds = 3
                     RPC()
            
                    if userInput2 == "2":
                        print("Have a good day")
            
            if playerWins > aiWins: #This is basically when the Player Wins and not the AI which needs it's own code since code cannot be dynamic 
                print("The player has won {} times, player won".format(playerWins))
                print("Would you like to play again?")
                print("Press '1' if you want to keep playing")
                print("Press '2' if you want to quit")
                userInput2 = input("Input code")
                if userInput2 == "1":
                    RPC()
                if userInput2 == "2":
                    print("Have a good day")
                    
        else:
                 print("Ending")
    except IndexError: #This is to help prevent Index errors on  our part like anything but one and three
         print("I said one through three")
         RPS()
    except ValueError: #If you put in Q, that isn't a number and we will immediately end the game
         print("That isn't a number bro")
         endgame()

def Menu(): #This is the menu, turned down from the orginal but you just choose wiether you want to play or not. I also make it sound like a test because I thought it would be a cool idea. 
    global userName
    print("Hello {}, welcome to Python Rock paper Scissors".format(userName))

    print("Would you like to play RPS?")

    print("1. Play Rock Paper Scissors")
    print("2. Do not play Rock Paper Scissors")

    userInput = input("Play or not, this is for testing")
    
    if userInput == "1":
        print("Transferring to game...")
        sleep(randint(0, 5))
        RPC()
        
    if userInput == "2":
        print("Thank you even coming here.")
        
playerinfo() #The reason I started with Player Information so I can globally set the player information more effectively which is because of logic of the rest of this program and because it is much easier.
Hello Chris, welcome to Python Rock paper Scissors
Would you like to play RPS?
1. Play Rock Paper Scissors
2. Do not play Rock Paper Scissors
Transferring to game...
0. Rock
1. Paper
2. Scissors
player chose ROCK
Mikaeli chose SCISSORS
Chris wins
Game ending. No more rounds.
The player has won 1 times, player won
Would you like to play again?
Press '1' if you want to keep playing
Press '2' if you want to quit
Have a good day
0. Rock
1. Paper
2. Scissors
player chose SCISSORS
Mikaeli chose SCISSORS
TIE
Game ending. No more rounds.
In [ ]: