Skip to content

Rock Paper Scissors Lizard Spock

  • Games

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 I made a reconfiguration for Flask API and implemented the game here on my website. Feel free to play it: The API game here on the blog

Enjoy!

### Import random module
import random

### list of options
options = ["Rock", "Paper", "Scissors", "Lizard", "Spock"]

def player_rock():
    if opponent == "Paper":
        print(opponent + " covers " + player + ", you loose!")
    elif opponent == "Scissors":
        print(player + " crushes " + opponent + ", you win!")
    elif opponent == "Lizard":
        print(player + " crushes " + opponent + ", you win!")
    elif opponent == "Spock":
        print(opponent + " vaporizes " + player + ", you loose!")

def player_paper():
    if opponent == "Rock":
        print(player + " covers " + opponent + ", you win!")
    elif opponent == "Scissors":
        print(opponent + " cuts " + player + ", you loose!")
    elif opponent == "Lizard":
        print(opponent + " eats " + player + ", you loose!")
    elif opponent == "Spock":
        print(player + " disproves " + opponent + ", you win!")

def player_scissors():
    if opponent == "Rock":
        print(opponent + " crushes " + player + ", you loose!")
    elif opponent == "Paper":
        print(player + " cuts " + opponent + ", you win!")
    elif opponent == "Lizard":
        print(player + " decapitates " + opponent + ", you win!")
    elif opponent == "Spock":
        print(opponent + " smashes " + player + ", you loose!")

def player_lizard():
    if opponent == "Rock":
        print(opponent + " crushes " + player + ", you loose!")
    elif opponent == "Paper":
        print(player + " eats " + opponent + ", you win!")
    elif opponent == "Scissors":
        print(opponent + " decapitates " + player + ", you loose!")
    elif opponent == "Spock":
        print(player + " poisons " + opponent + ", you win!")

def player_spock():
    if opponent == "Rock":
        print(player + " vaporizes " + opponent + ", you win!")
    elif opponent == "Paper":
        print(opponent + " disproves " + player + ", you loose!")
    elif opponent == "Scissors":
        print(player + " smashes " + opponent + ", you win!")
    elif opponent == "Lizard":
        print(opponent + " poisons " + player + ", you loose!")

### The main program
while True:
    print("[+] Game Time! [+]")
    for item in options:
            print(item, end=" ") 
    try:
        
        player = input("Your choice: "); ### players variable
        for i in options:
            if i != player:
                continue
            else:
                break
    except KeyboardInterrupt:
        print("Bye")
        quit()
    except:
        print("Something wrong")

    opponent = random.choice(options) ### computers variable

    if player == opponent:
        print("Draw!")
    if player == "Rock":
        player_rock()
    if player == "Paper":
        player_paper()
    if player == "Scissors":
        player_scissors()
    if player == "Lizard":
        player_lizard()
    if player == "Spock":
        player_spock()

    opponent = None