Advertisement
asweigart

Rock Paper Scissors Spock Lizard

Jul 20th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. import time, sys,random
  2.  
  3. wins = 0
  4. losses = 0
  5. ties = 0
  6.  
  7. # Display the instructions.
  8. print('Rock, Paper, Scissors, Spock, Lizard')
  9. print('- Rock beats scissors and lizard')
  10. print('- Paper beats rock and spock')
  11. print('- Scissors beats paper and lizard')
  12. print('- Spock beats scissors and rock')
  13. print('- Lizard beats spock and paper')
  14.  
  15. while True:
  16. # Display how many wins, losses, and ties.
  17. print(wins, 'Wins,', losses, 'Losses,', ties, 'Ties')
  18.  
  19. # Have the player enter their move.
  20. print('Enter your move: (r)ock, (s)cissors, (p)aper, spoc(k), (l)izard, (q)uit')
  21. move = input().upper()
  22.  
  23. # Quit the program if the player entered Q
  24. if move == 'Q':
  25. print('Thanks for playing!')
  26. sys.exit()
  27.  
  28. # Build up suspense with a count.
  29. if move == 'R':
  30. print('ROCK versus...')
  31. elif move == 'P':
  32. print('PAPER versus...')
  33. elif move == 'S':
  34. print('SCISSORS versus...')
  35. elif move == 'K':
  36. print('SPOCK versus...')
  37. elif move == 'L':
  38. print('LIZARD versus...')
  39. time.sleep(0.5)
  40.  
  41. print('1..')
  42. time.sleep(0.5)
  43.  
  44. print('2...')
  45. time.sleep(0.5)
  46.  
  47. print('3...')
  48. time.sleep(0.5)
  49.  
  50. # Decide what move the computer made.
  51. computerMove = random.choice(['ROCK', 'SCISSORS', 'PAPER', 'SPOCK', 'LIZARD'])
  52. print(computerMove)
  53.  
  54.  
  55. # Show the win/lose/tie result.
  56. if computerMove == 'ROCK':
  57. computerMove = 'R'
  58. elif computerMove == 'SCISSORS':
  59. computerMove = 'S'
  60. elif computerMove == 'PAPER':
  61. computerMove = 'P'
  62. elif computerMove == 'SPOCK':
  63. computerMove = 'K'
  64. elif computerMove == 'LIZARD':
  65. computerMove = 'L'
  66.  
  67. if move == computerMove:
  68. print('It is a tie!')
  69. ties += 1
  70. elif move == 'R' and (computerMove == 'S' or computerMove == 'L'):
  71. print('You won!')
  72. wins += 1
  73. elif move == 'S' and (computerMove == 'P' or computerMove == 'L'):
  74. print('You won!')
  75. wins += 1
  76. elif move == 'P' and (computerMove == 'R' or computerMove == 'K'):
  77. print('You won!')
  78. wins += 1
  79. elif move == 'K' and (computerMove == 'S' or computerMove == 'R'):
  80. print('You won!')
  81. wins += 1
  82. elif move == 'L' and (computerMove == 'K' or computerMove == 'P'):
  83. print('You won!')
  84. wins += 1
  85.  
  86. else:
  87. print('You lose!')
  88. losses += 1
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement