/
First
127 lines (120 loc) · 4.62 KB
/
First
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import time
import random
def main():
"""Body of program. Playing 'Rock, Paper, Scissors' against a bot"""
# Introduction
print("")
print("Rock, Paper, Scissors")
print("-------------------------")
completegame = False
while not completegame:
print("")
time.sleep(1)
"""RUNS USER'S SELECTION PHASE"""
user_selection = False
while not user_selection:
"""Runs the user's turn"""
try:
print("Please choose a selection from the following moves...")
print("")
time.sleep(2)
print("1) ROCK")
time.sleep(0.5)
print("2) PAPER")
time.sleep(0.5)
print("3) SCISSORS")
print("")
time.sleep(0.7)
usermove = int(input("Chosen move (enter a number):"))
if usermove == 1:
time.sleep(0.5)
print("You chose to use ROCK. Is this correct?")
time.sleep(2)
confirmselection = input("Type 'y' for YES or any other input for NO")
if confirmselection == 'y':
usermove = "ROCK"
user_selection = True
else:
print("")
time.sleep(1)
print("You chose to change your move...")
print("")
time.sleep(2)
elif usermove == 2:
time.sleep(0.5)
print("You chose to use PAPER. Is this correct?")
time.sleep(2)
confirmselection = input("Type 'y' for YES or any other input for NO")
if confirmselection == 'y':
usermove = "PAPER"
user_selection = True
else:
print("")
time.sleep(1)
print("You chose to change your move...")
print("")
time.sleep(2)
elif usermove == 3:
time.sleep(0.5)
print("You chose to use SCISSORS. Is this correct?")
time.sleep(2)
confirmselection = input("Type 'y' for YES or any other input for NO")
if confirmselection == 'y':
usermove = "SCISSORS"
user_selection = True
else:
print("")
time.sleep(1)
print("You chose to change your move...")
print("")
time.sleep(2)
except:
print("Invalid Input")
"""RUNS COMPUTER'S SELECTION PHASE"""
botmove = int(random.randint(1, 3)) # Declares the computer's move
if botmove == 1:
botmove = "ROCK"
elif botmove == 2:
botmove = "PAPER"
elif botmove == 3:
botmove = "SCISSORS"
"""COMPARES CHOICES AND DECLARES A WINNER"""
print("")
print("Declaring winner...")
time.sleep(2)
print("")
print("You chose", usermove)
time.sleep(2)
print("The computer chose", botmove)
time.sleep(1)
if (usermove == "ROCK" and botmove == "ROCK") or \
(usermove == "PAPER" and botmove == "PAPER") or \
(usermove == "SCISSORS" and botmove == "SCISSORS"):
print("")
print("Both participants chose the same!")
time.sleep(2)
print("")
print("Restarting game...")
print("")
time.sleep(3.5)
print("-----------------------------------------------")
print("")
elif (usermove == "ROCK" and botmove == "SCISSORS") or \
(usermove == "PAPER" and botmove == "ROCK") or \
(usermove == "SCISSORS" and botmove == "PAPER"):
print("")
print("You WIN!!!!")
completegame = True
elif (botmove == "ROCK" and usermove == "SCISSORS") or \
(botmove == "PAPER" and usermove == "ROCK") or \
(botmove == "SCISSORS" and usermove == "PAPER"):
print("")
print("The computer won!")
time.sleep(2)
print("")
print("Restarting game...")
print("")
time.sleep(3.5)
print("-----------------------------------------------")
print("")
main()