Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import time
- import numpy as np
- def main():
- # list of moves
- moves = ["rock", "paper", "scissors", "lizard", "spock"]
- # results matrix
- # comp: rock , paper , scissors, lizard, spock /user
- results = np.array([["It's a tie!", "You lose!", "You win!", "You win!", "You lose!"], #rock
- ["You win!", "It's a tie!", "You lose!", "You lose!", "You win!"], #paper
- ["You lose!", "You win!", "It's a tie!", "You win!", "You lose!"], #scissors
- ["You lose!", "You win!", "You lose!", "It's a tie!", "You win!"], #lizard
- ["You win!", "You lose!", "You win!", "You lose!", "It's a tie!"]]) #spock
- # generate move for the computer
- ind_comp = randint(0,4)
- # Intro
- print ("Hi! Let's play rock paper scissors lizard spock")
- print ("")
- time.sleep(1)
- # Ask for user's move
- move_user = input("What's your move? ")
- # assing index to move
- ind_user = moves.index(move_user)
- # give results to the user
- print("The computer played " + moves[ind_comp] + " and you played " + move_user + ". " + results[ind_user, ind_comp])
- main()
Add Comment
Please, Sign In to add comment