Created
August 4, 2017 17:27
-
-
Save lafftar/4aabbd7d037f69f06d6891d32e4b3b1e to your computer and use it in GitHub Desktop.
Basic Rock/Paper/Scissors Game in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
rerun = True | |
def computer_result(): | |
# Revealing What The Computer Played | |
if computer_play == 'R': | |
print('I Played Rock') | |
elif computer_play == 'S': | |
print('I Played Scissors') | |
elif computer_play == 'P': | |
print('I Played Paper') | |
# INTRO: | |
def intro(): | |
print('Hi, Welcome to the Rock, Paper, Scissors Game.') | |
time.sleep(2) | |
print('You Choose a Play: Rock, Paper or Scissors. The Computer Has Already Chosen a Play.') | |
time.sleep(3) | |
print('Can You Beat Pre Determined Chance?') | |
time.sleep(3) | |
print('Rules of this game are basic:') | |
time.sleep(1) | |
print('1) Rock Beats Scissors.') | |
time.sleep(1) | |
print('2) Paper Beats Rock.') | |
time.sleep(1) | |
print('3) Scissors Beats Paper.') | |
time.sleep(2) | |
print('Can You Beat The Computer?') | |
intro() | |
while rerun: | |
# R = Rock | |
# S = Scissors | |
# P = Paper | |
# Computer Plays | |
computer_play = random.randint(1, 3) | |
if computer_play == 1: | |
computer_play = 'R' | |
elif computer_play == 2: | |
computer_play = 'S' | |
elif computer_play == 3: | |
computer_play = 'P' | |
# User Plays | |
time.sleep(1) | |
user_play = int(input("Type '1' to Play Rock, Type '2' to Play Scissors, Type '3' to Play Paper: ")) | |
if user_play == 1: | |
user_play = 'R' | |
time.sleep(0.4) | |
print('I See You Played Rock') | |
elif user_play == 2: | |
user_play = 'S' | |
time.sleep(0.4) | |
print('I See You Played Scissors') | |
elif user_play == 3: | |
user_play = 'P' | |
time.sleep(0.4) | |
print('I See You Played Paper') | |
# Stalemate | |
if (user_play == 'R' and computer_play == 'R') or (user_play == 'P' and computer_play == 'P') \ | |
or (user_play == 'S' and computer_play == 'S'): | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('Stalemate...We Both Chose The Same Thing.') | |
# User Wins | |
if user_play == 'R' and computer_play == 'S': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('You Win. But I Do No Accept Defeat.') | |
if user_play == 'P' and computer_play == 'R': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('You Win. But I Do No Accept Defeat.') | |
if user_play == 'S' and computer_play == 'P': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('You Win. But I Do No Accept Defeat.') | |
# Computer Wins | |
if computer_play == 'R' and user_play == 'S': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('I Win. And Will Be Taking Your Status as The Superior Being.') | |
if computer_play == 'P' and user_play == 'R': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('I Win. And Will Be Taking Your Status as The Superior Being.') | |
if computer_play == 'S' and user_play == 'P': | |
time.sleep(1.2) | |
computer_result() | |
time.sleep(1.2) | |
print('I Win. And Will Be Taking Your Status as The Superior Being.') | |
# To loop or not to loop. | |
time.sleep(1.2) | |
replay = input('Would You Like to Play Again? Y/N: ') | |
if replay == 'Y' or replay == 'y': | |
continue | |
else: | |
rerun = False | |
print('Thank You For Playing.') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment