Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, sys,random
- wins = 0
- losses = 0
- ties = 0
- # Display the instructions.
- print('Rock, Paper, Scissors, Spock, Lizard')
- print('- Rock beats scissors and lizard')
- print('- Paper beats rock and spock')
- print('- Scissors beats paper and lizard')
- print('- Spock beats scissors and rock')
- print('- Lizard beats spock and paper')
- while True:
- # Display how many wins, losses, and ties.
- print(wins, 'Wins,', losses, 'Losses,', ties, 'Ties')
- # Have the player enter their move.
- print('Enter your move: (r)ock, (s)cissors, (p)aper, spoc(k), (l)izard, (q)uit')
- move = input().upper()
- # Quit the program if the player entered Q
- if move == 'Q':
- print('Thanks for playing!')
- sys.exit()
- # Build up suspense with a count.
- if move == 'R':
- print('ROCK versus...')
- elif move == 'P':
- print('PAPER versus...')
- elif move == 'S':
- print('SCISSORS versus...')
- elif move == 'K':
- print('SPOCK versus...')
- elif move == 'L':
- print('LIZARD versus...')
- time.sleep(0.5)
- print('1..')
- time.sleep(0.5)
- print('2...')
- time.sleep(0.5)
- print('3...')
- time.sleep(0.5)
- # Decide what move the computer made.
- computerMove = random.choice(['ROCK', 'SCISSORS', 'PAPER', 'SPOCK', 'LIZARD'])
- print(computerMove)
- # Show the win/lose/tie result.
- if computerMove == 'ROCK':
- computerMove = 'R'
- elif computerMove == 'SCISSORS':
- computerMove = 'S'
- elif computerMove == 'PAPER':
- computerMove = 'P'
- elif computerMove == 'SPOCK':
- computerMove = 'K'
- elif computerMove == 'LIZARD':
- computerMove = 'L'
- if move == computerMove:
- print('It is a tie!')
- ties += 1
- elif move == 'R' and (computerMove == 'S' or computerMove == 'L'):
- print('You won!')
- wins += 1
- elif move == 'S' and (computerMove == 'P' or computerMove == 'L'):
- print('You won!')
- wins += 1
- elif move == 'P' and (computerMove == 'R' or computerMove == 'K'):
- print('You won!')
- wins += 1
- elif move == 'K' and (computerMove == 'S' or computerMove == 'R'):
- print('You won!')
- wins += 1
- elif move == 'L' and (computerMove == 'K' or computerMove == 'P'):
- print('You won!')
- wins += 1
- else:
- print('You lose!')
- losses += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement