Rock Paper Scissors Lizard Spock
Whether you are a beginner or an expert, programming offers endless possibilities for creating innovative and interesting projects. One such project is the game of Rock Paper Scissors Lizard Spock, made popular by the TV show “The Big Bang Theory.”
In this game, player and python’s random module compete against each other by selecting one of the five possible options: rock, paper, scissors, lizard, or Spock. The game is based on a hierarchy of choices where each choice beats two other choices and is beaten by two other choices. For example, rock beats scissors and lizard but is beaten by paper and Spock.
I have written a Python program that allows you to play Rock Paper Scissors Lizard Spock against a computer. The program is designed to be easy to use and understand, making it perfect for beginners who are new to programming.
The player is prompted to select the choice by typing in the corresponding number. The computer randomly selects its choice, and the winner is determined based on the hierarchy of choices.
In conclusion, this is simple command line programming game which can be a fun and rewarding experience by improving the Python skills. Simple game like Rock Paper Scissors Lizard Spock is just one example of the many possibilities that programming offers. I hope you enjoy playing this game and learning more about Python programming.
I loaded the code below and you can check it out on my Github.
Also feel free to play the game on this link.
import random
# list of options
options = ["Rock", "Paper", "Scissors", "Lizard", "Spock"]
def player_rock(player, opponent):
player_result = "BAZINGA!"
if opponent == "Paper":
player_result = opponent + " covers " + player + ", you loose!"
if opponent == "Scissors":
player_result = player + " crushes " + opponent + ", you win!"
if opponent == "Lizard":
player_result = player + " crushes " + opponent + ", you win!"
if opponent == "Spock":
player_result = opponent + " vaporizes " + player + ", you loose!"
return player_result
def player_paper(player, opponent):
player_result = "BAZINGA!"
if opponent == "Rock":
player_result = player + " covers " + opponent + ", you win!"
if opponent == "Scissors":
player_result = opponent + " cuts " + player + ", you loose!"
if opponent == "Lizard":
player_result = opponent + " eats " + player + ", you loose!"
if opponent == "Spock":
player_result = player + " disproves " + opponent + ", you win!"
return player_result
def player_scissors(player, opponent):
player_result = "BAZINGA!"
if opponent == "Rock":
player_result = opponent + " crushes " + player + ", you loose!"
if opponent == "Paper":
player_result = player + " cuts " + opponent + ", you win!"
if opponent == "Lizard":
player_result = player + " decapitates " + opponent + ", you win!"
if opponent == "Spock":
player_result = opponent + " smashes " + player + ", you loose!"
return player_result
def player_lizard(player, opponent):
player_result = "BAZINGA!"
if opponent == "Rock":
player_result = opponent + " crushes " + player + ", you loose!"
if opponent == "Paper":
player_result = player + " eats " + opponent + ", you win!"
if opponent == "Scissors":
player_result = opponent + " decapitates " + player + ", you loose!"
if opponent == "Spock":
player_result = player + " poisons " + opponent + ", you win!"
return player_result
def player_spock(player, opponent):
player_result = "BAZINGA!"
if opponent == "Rock":
player_result = player + " vaporizes " + opponent + ", you win!"
if opponent == "Paper":
player_result = opponent + " disproves " + player + ", you loose!"
if opponent == "Scissors":
player_result = player + " smashes " + opponent + ", you win!"
if opponent == "Lizard":
player_result = opponent + " poisons " + player + ", you loose!"
return player_result
# The main program
def main(player_choice):
if player_choice != None:
player = player_choice
opponent = random.choice(options) # computers variable
if player == opponent:
result = "Draw!"
if player == "Rock":
result = player_rock(player, opponent)
if player == "Paper":
result = player_paper(player, opponent)
if player == "Scissors":
result = player_scissors(player, opponent)
if player == "Lizard":
result = player_lizard(player, opponent)
if player == "Spock":
result = player_spock(player, opponent)
return result
return result