-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrock-paper-scissors.py
More file actions
69 lines (62 loc) · 2.33 KB
/
rock-paper-scissors.py
File metadata and controls
69 lines (62 loc) · 2.33 KB
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
#The classic game: rock, paper and scissors. The winner is the first to reach 3 points
import random
#Score
playerScore = 0
botScore = 0
restart = 1
while restart == 1 :
print("1-Rock")
print("2-Paper")
print("1-Scissors")
player = int(input("Choose your attack: "))
bot = random.randint(1,3)
#Case 1: The player chooses Rock
if player == 1 and bot == 1:
print("The bot has chosen Rock. It's a tie")
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 1 and bot == 2:
print("The bot has chosen Paper. The bot wins")
botScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 1 and bot == 3:
print("The bot has chosen Scissors. You win")
playerScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
#Case 2: The player chooses Paper
if player == 2 and bot == 1:
print("The bot has chosen Rock. You win")
playerScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 2 and bot == 2:
print("The bot has chosen Paper. It's a tie")
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 2 and bot == 3:
print("The bot has chosen Scissors. The bot wins")
botScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
#Case 3: The player chooses Scissors
if player == 3 and bot == 1:
print("The bot has chosen Rock. The bot wins")
botScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 3 and bot == 2:
print("The bot has chosen Paper. You win")
playerScore+=1
print(f"Score : Player {playerScore} - Bot {botScore}")
elif player == 3 and bot == 3:
print("The bot has chosen Scissors. It's a tie")
print(f"Score : Player {playerScore} - Bot {botScore}")
#The player wins:
if playerScore >= 3 and botScore < 3:
playerScore = 0
botScore = 0
print("1-Yes")
print("2-No")
restart = int(input("Do you want to restart the game: "))
#The bot wins:
if playerScore < 3 and botScore >= 3:
playerScore = 0
botScore = 0
print("1-Yes")
print("2-No")
restart = int(input("Do you want to restart the game: "))