-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (46 loc) · 1.44 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import random
import datetime
# Starting values
game_list = ['Rock', 'Paper', 'Scissors']
computer = c = 0
command = cmd = 0
# Initial state
time = datetime.date.today()
print(time)
print("Score: Computer: " + str(c) + " Player: " + str(cmd))
# The game loop
Run = True
while Run:
# Check if either player has reached the winning score before starting a new round
if c == 3:
print("Computer Won")
break
elif cmd == 3:
print("Player Won")
break
computer_choice = random.choice(game_list)
command = input("Rock, Paper, Scissors or Quit: ")
# Check if the player wants to quit
if command.lower() == 'quit':
break
if command in game_list:
print("Player: " + command)
print("Computer: " + computer_choice)
# Determine the winner of the round
if command == computer_choice:
print("Let's go")
elif (command == 'Rock' and computer_choice == 'Scissors') or \
(command == 'Paper' and computer_choice == 'Rock') or \
(command == 'Scissors' and computer_choice == 'Paper'):
print("Player won!")
cmd += 1
else:
print("Computer won")
c += 1
# Print the current score
print("--------------")
print("Score: Computer: " + str(c) + " Player: " + str(cmd))
print("--------------")
else:
print("Wrong command!")
print("Game Over!")