Skip to content

Instantly share code, notes, and snippets.

@royalPanic
Created May 11, 2019 00:54
Show Gist options
  • Save royalPanic/173e034bf6010ffc4e0bcc3dde50e873 to your computer and use it in GitHub Desktop.
Save royalPanic/173e034bf6010ffc4e0bcc3dde50e873 to your computer and use it in GitHub Desktop.
The demo Rock Paper Scissors game code.
#rock paper scissors game
import random
#variables
win_flag = str("false")
error = str("false")
play = ""
signs = ["rock", "paper", "scissors"]
#functions
def playerName():
return(input("Enter Your Name... "))
def instructPlayer():
print("---------------")
print("Hello! Welcome to Rock Paper Scissors! The rules are quite simple. You will pick a sign to throw, and the computer will do the same. (It will do so before you to eliminate any possibility of cheating) Every sign can cancel and can be cancelled by one other sign. ROCK will cancel out SCISSORS, but PAPER will cancel out ROCK.")
print()
print("ROCK loses to PAPER but beats SCISSORS.")
print("PAPER loses to SCISSORS but beats ROCK.")
print("SCISSORS loses to ROCK but beats PAPER.")
print("---------------")
def compareSigns(plr,cpu):
#if the player throws rock
if plr == "rock" and cpu == "rock":
return("It's a Tie!")
if plr == "rock" and cpu == "paper":
return("The CPU Wins!")
if plr == "rock" and cpu == "scissors":
return("The Player Wins!")
#if the player throws paper
if plr == "paper" and cpu == "paper":
return("It's a Tie!")
if plr == "paper" and cpu == "scissors":
return("The CPU Wins!")
if plr == "paper" and cpu == "rock":
return("The Player Wins!")
#if the player throws scissors
if plr == "scissors" and cpu == "scissors":
return("It's a Tie!")
if plr == "scissors" and cpu == "rock":
return("The CPU Wins!")
if plr == "scissors" and cpu == "paper":
return("The Player Wins!")
if plr == "gauntlet":
print("'Reality can be whatever I want.' *snaps*")
return("The Player Wins!")
def beginGame():
print("---------------")
cpu_choice = str(signs[random.randint(0,2)])
print("The CPU has chosen!")
print()
player_choice = input("Make your choice! ['rock', 'paper' or 'scissors']: ")
print()
print("You have chosen", (player_choice+"!"))
print("The computer has chosen", (cpu_choice+"!"))
print()
print(compareSigns(player_choice,cpu_choice))
print("Rock Paper Scissors Demo Game by @royal_Panic")
print("---------------")
player = playerName()
print("Welcome,", (player+","), "to Rock Paper Scissors!")
if player == "Thanos" or player == "thanos":
print("reality = str('whatever you want')")
instruct = input("Would you like to learn how to play? [Yes or No]: ")
if instruct == "Yes" or instruct == "yes":
instructPlayer()
input("Press ENTER to Start... ")
while True:
beginGame()
if instruct == "No" or instruct == "no":
while True:
beginGame()
@spicesouls
Copy link

Cool code. Things I'd change:

instruct = input("Would you like to learn how to play? [Yes or No]: ")
if instruct == "Yes" or instruct == "yes":

I'd just make the instruct an input with .title() to make the first letter capital, that way you wont need that or. Just "Yes".

Furthermore, just a tip: when printing multiple lines you dont have to print for each line, you can just use triple quotes, like:

print('''
hello
this
is
my
banner
:)
''')

@royalPanic
Copy link
Author

Yeah, this is a bit old, and actually a game I made for someone else. Looking back on it, I'd be more apt to use .lower() for the input, and probably just a newline character for the multiline prints,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment