Skip to content

Instantly share code, notes, and snippets.

Created September 22, 2014 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7468deab656bcf12a494 to your computer and use it in GitHub Desktop.
Save anonymous/7468deab656bcf12a494 to your computer and use it in GitHub Desktop.
from random import randint
import os
print("Welcome to my Rock, Papers, Scissors game!")
print("Enter your guess to beat the computer and win")
print("Press 1 on your keyboard to play against the computer.")
print("Press 2 to play against a friend, or press any other key to exit.")
answer = input(" ")
iAnswer = int(answer)
condition1 = True
condition2 = True
while condition1 or condition2:
if iAnswer == 1:
os.system('CLS')
user_score = 0
ai_score = 0
for x in range(1,4):
uinput = ""
user_choice = ""
user_input = 0
user_input = input("Choose rock, paper, or scissor by choosing 1,2, or 3 respectively: ")
os.system('CLS')
if user_input == "1":
user_choice = "rock"
elif user_input == "2":
user_choice = "paper"
elif user_input == "3":
user_choice = "scissor"
rand = randint(1,30)
ai_choice = ""
if rand <= 10:
ai_choice = "rock"
elif rand <= 20:
ai_choice = "paper"
elif rand <= 30:
ai_choice = "scissor"
if ai_choice == "rock" and user_choice != "paper" and user_choice != "rock":
ai_score = ai_score + 1
elif ai_choice == "paper" and user_choice != "scissor" and user_choice != "paper":
ai_score = ai_score + 1
elif ai_choice == "scissor" and user_choice != "rock" and user_choice != "scissor":
ai_score = ai_score + 1
elif user_choice == ai_choice:
print("Tie!\n")
else:
user_score = user_score + 1
print("Your choice: ", user_choice)
print("The computer's choice: ", ai_choice, "\n")
print("Your score: ", user_score)
print("Computer score: ", ai_score, "\n")
print("You have ", 3-x," lives left.")
if user_score > ai_score:
print("You win ", user_score, " to ", ai_score, "\n")
elif user_score == ai_score:
print("You tied with the computer!")
else:
print("The computer wins ", ai_score, " to ",user_score, "\n")
user_score = 0
ai_score = 0
#paste code here
elif iAnswer == 2:
os.system('CLS')
one_score = 0
two_score = 0
print("Choose either 1, 2, or 3 on your keyboard to select")
print("rock, paper or scissors respectively.\n")
for x in range(1,4):
pOne_input = ""
pTwo_input = ""
pOne_choice = ""
pTwo_choice = ""
print("Player one goes first.\n")
pOne_input = input("")
os.system('CLS')
print("Ok, now player one should turn away while player two makes his/her choice: ")
pTwo_input = input("")
os.system('CLS')
if pOne_input == "1":
pOne_choice = "rock"
elif pOne_input == "2":
pOne_choice = "paper"
elif pOne_input == "3":
pOne_choice = "scissor"
if pTwo_input == "1":
pTwo_choice = "rock"
elif pTwo_input == "2":
pTwo_choice = "paper"
elif pTwo_input == "3":
pTwo_choice = "scissor"
if pTwo_choice == "rock" and pOne_choice != "paper" and pOne_choice != "rock":
two_score = two_score + 1
elif pTwo_choice == "paper" and pOne_choice != "scissor" and pOne_choice != "paper":
two_score = two_score + 1
elif pTwo_choice == "scissor" and pOne_choice != "rock" and pOne_choice != "scissor":
two_score = two_score + 1
elif pOne_choice == pTwo_choice:
print("Tie!\n")
else:
one_score = one_score + 1
print("Player one's choice: ", pOne_choice)
print("Player two's choice: ", pTwo_choice, "\n")
print("Player one's score: ", one_score)
print("Player two's score: ", two_score, "\n")
if one_score > two_score:
print("Player one wins ", one_score, " to ", two_score, "\n")
elif one_score == two_score:
print("It's a tie!")
else:
print("Player two wins ", two_score, " to ",one_score, "\n")
elif iAnswer == 3:
sys.exit()
else:
while iAnswer != 1 and iAnswer != 2 and iAnswer != 3:
print("Invalid input. Please enter 1 to play against the computer.\n")
print("Enter 2 to play with friend, or press 3 to exit.")
answer = input(" ")
iAnswer = int(answer)
print("Thank you for playing! Would you like to try again?")
print("If so, press 1 on your keyboard to play against the computer")
print("press 2 to play against a friend.")
print("Press 3 to exit.")
answer = input(" ")
iAnswer = int(answer)
if iAnswer == 1 and iAnswer != 2:
condition1 = True
condition2 = False
elif iAnswer == 2 and iAnswer != 1:
condition2 = True
condition1 = False
elif iAnswer == 3 and iAnswer != 1 and iAnswer != 2:
condition2 = False
condition1 = False
sys.exit()
else:
while iAnswer != 1 and iAnswer != 2 and iAnswer != 3:
print("Invalid input. Please enter either 1 play against the computer, 2 to play against a friend or 3 to exit")
print("not other number or characters")
while condition1:
user_score = 0
ai_score = 0
os.system('CLS')
for x in range(1,4):
uinput = ""
user_choice = ""
user_input = 0
user_input = input("Choose rock, paper, or scissor by choosing 1,2, or 3 respectively: ")
os.system('CLS')
print("You have ", 3-x," lives left.")
if user_input == "1":
user_choice = "rock"
elif user_input == "2":
user_choice = "paper"
elif user_input == "3":
user_choice = "scissor"
rand = randint(1,30)
ai_choice = ""
if rand <= 10:
ai_choice = "rock"
elif rand <= 20:
ai_choice = "paper"
elif rand <= 30:
ai_choice = "scissor"
if ai_choice == "rock" and user_choice != "paper" and user_choice != "rock":
ai_score = ai_score + 1
elif ai_choice == "paper" and user_choice != "scissor" and user_choice != "paper":
ai_score = ai_score + 1
elif ai_choice == "scissor" and user_choice != "rock" and user_choice != "scissor":
ai_score = ai_score + 1
elif user_choice == ai_choice:
print("Tie!\n")
else:
user_score = user_score + 1
print("Your choice: ", user_choice)
print("The computer's choice: ", ai_choice, "\n")
print("Your score: ", user_score)
print("Computer score: ", ai_score, "\n")
if user_score > ai_score:
print("You win ", user_score, " to ", ai_score, "\n")
elif user_score == ai_score:
print("You tied with the computer!")
else:
print("The computer wins ", ai_score, " to ",user_score, "\n")
print("Thank you for playing! Would you like to try again?")
print("If so, press 1 on your keyboard to play against the computer")
print("press 2 to play against a friend.")
print("Press 3 to exit.")
answer = input(" ")
iAnswer = int(answer)
if iAnswer == 1 and iAnswer != 2:
condition1 = True
condition2 = False
elif iAnswer == 2 and iAnswer != 1:
condition2 = True
condition1 = False
elif iAnswer == 3 and iAnswer != 1 and iAnswer != 2:
condition2 = False
condition1 = False
sys.exit()
else:
while iAnswer != 1 and iAnswer != 2 and iAnswer != 3:
print("Invalid input. Please enter either 1 play against the computer, 2 to play against a friend or 3 to exit")
print("not other number or characters")
while condition2:
os.system('CLS')
one_score = 0
two_score = 0
print("Choose either 1, 2, or 3 on your keyboard to select")
print("rock, paper or scissors respectively.\n")
for x in range(1,4):
pOne_input = ""
pTwo_input = ""
pOne_choice = ""
pTwo_choice = ""
print("Player one goes first.\n")
pOne_input = input("")
os.system('CLS')
print("Ok, now player one should turn away while player two makes his/her choice: ")
pTwo_input = input("")
os.system('CLS')
if pOne_input == "1":
pOne_choice = "rock"
elif pOne_input == "2":
pOne_choice = "paper"
elif pOne_input == "3":
pOne_choice = "scissor"
if pTwo_input == "1":
pTwo_choice = "rock"
elif pTwo_input == "2":
pTwo_choice = "paper"
elif pTwo_input == "3":
pTwo_choice = "scissor"
if pTwo_choice == "rock" and pOne_choice != "paper" and pOne_choice != "rock":
two_score = two_score + 1
elif pTwo_choice == "paper" and pOne_choice != "scissor" and pOne_choice != "paper":
two_score = two_score + 1
elif pTwo_choice == "scissor" and pOne_choice != "rock" and pOne_choice != "scissor":
two_score = two_score + 1
elif pOne_choice == pTwo_choice:
print("Tie!\n")
else:
one_score = one_score + 1
print("Player one's choice: ", pOne_choice)
print("Player two's choice: ", pTwo_choice, "\n")
print("Player one's score: ", one_score)
print("Player two's score: ", two_score, "\n")
if one_score > two_score:
print("Player one wins ", one_score, " to ", two_score, "\n")
elif one_score == two_score:
print("It's a tie!")
else:
print("Player two wins ", two_score, " to ",one_score, "\n")
print("Thank you for playing! Would you like to try again?")
print("If so, press 1 on your keyboard to play against the computer")
print("press 2 to play against a friend.")
print("Press 3 to exit.")
answer = input(" ")
iAnswer = int(answer)
if iAnswer == 1 and iAnswer != 2:
condition1 = True
condition2 = False
elif iAnswer == 2 and iAnswer != 1:
condition2 = True
condition1 = False
elif iAnswer == 3 and iAnswer != 1 and iAnswer != 2:
condition2 = False
condition1 = False
sys.exit()
else:
while iAnswer != 1 and iAnswer != 2 and iAnswer != 3:
print("Invalid input. Please enter either 1 play against the computer, 2 to play against a friend or 3 to exit")
print("not other number or characters")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment