daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Apr 25th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randint
  2. import time
  3. import numpy as np
  4.  
  5. def main():
  6.  
  7.   # list of moves
  8.   moves = ["rock", "paper", "scissors", "lizard", "spock"]
  9.  
  10.   # results matrix
  11.   #               comp:  rock  ,        paper  ,    scissors,     lizard,       spock     /user
  12.   results = np.array([["It's a tie!", "You lose!", "You win!", "You win!", "You lose!"],  #rock
  13.                       ["You win!", "It's a tie!", "You lose!", "You lose!", "You win!"],  #paper
  14.                       ["You lose!", "You win!", "It's a tie!", "You win!", "You lose!"],  #scissors
  15.                       ["You lose!", "You win!", "You lose!", "It's a tie!", "You win!"],  #lizard
  16.                       ["You win!", "You lose!", "You win!", "You lose!", "It's a tie!"]]) #spock
  17.  
  18.   # generate move for the computer
  19.   ind_comp = randint(0,4)
  20.  
  21.   # Intro
  22.   print ("Hi! Let's play rock paper scissors lizard spock")
  23.   print ("")
  24.   time.sleep(1)
  25.  
  26.   # Ask for user's move
  27.   move_user = input("What's your move? ")
  28.  
  29.   # assing index to move
  30.   ind_user = moves.index(move_user)
  31.  
  32.   # give results to the user
  33.   print("The computer played " + moves[ind_comp] + " and you played " + move_user + ". " + results[ind_user, ind_comp])
  34.  
  35. main()
RAW Paste Data
Top