Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def main():
- playerName=introduction()
- humplayer=hum_player()
- compchoice=com_player()
- tieScore = 0
- humScore=0
- comScore=0
- humplayer=input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): ")
- while humplayer != -1:
- compchoice=com_player()
- result= evaluate_Game(humplayer,compchoice,playerName)
- if result==0:
- print("It's a tie!")
- tieScore+=1
- elif result==1:
- comScore+=1
- else:
- humScore+=1
- humplayer=input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): ")
- print(statistics(playerName,humScore,comScore,tieScore))
- def introduction():
- print("Welcome to the game of Rock, Paper, Scissors. You will be playing against the computer.")
- name= input("What is your name? ")
- print("Here are the rules", name+":")
- print(" If a player chooses Rock and the other chooses Scissors, Rock wins.")
- print(" If a player chooses Scissors and the other chooses Paper, Scissors wins.")
- print(" If a player chooses Paper and the other chooses Rock, Paper wins.")
- print(" If both players make the same choice, it's a tie.")
- print(" Enter -1 to quit the game ")
- return name
- def hum_player():
- choice = int(input("Enter your move (0 for Rock, 1 for Paper, and 2 for Scissors): "))
- return choice
- def com_player():
- random_Num = random.randint(0,2)
- return(random_Num)
- def evaluate_Game(humplayer,compchoice,playerName):
- a = "Rock"
- b="Paper"
- c="Scissors"
- if humplayer==0:
- if compchoice==0:
- return 0
- elif compchoice==1:
- print(playerName, "plays ",a," computer plays",b)
- print("Paper covers Rock, Computer wins!")
- return 1
- else:
- print(playerName, "plays",a,"computer plays", c)
- print("Rock crushes Scissors ,", playerName," wins!")
- return 2
- elif humplayer==1:
- if compchoice==0:
- print(name,"plays",b," computer plays", a)
- print("Paper covers Rock.", playerName,"wins!")
- return 2
- elif compchoice==1:
- print(playerName,"plays", b," computer plays" , b)
- print("It's a tie!")
- return 0
- else:
- print(playerName, "plays", b,"computer plays", c)
- print("Scissors cuts Paper. Computer wins!")
- return 1
- else:
- if compchoice==0:
- print(playerName, "plays", c," computer plays", a)
- print("Rock breaks Scissors. Computer wins!")
- return 1
- elif compchoice==1:
- print(playerName, "plays", c, " computer plays", b)
- print("Scissors cuts Paper." , playerName, "wins!")
- return 2
- else:
- print(playerName, "plays", c," computer plays", c)
- print("It's a tie!")
- return 0
- def statistics(playerName,humScore,tieScore,comScore):
- print("There were", tieScore+comScore+humscore, "games:", playerName, "won", humScore, "games, the computer won", comScore, "games and there were", tieScore, "ties.")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement