-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrock_paper_scissors2.py
More file actions
74 lines (68 loc) · 2.1 KB
/
rock_paper_scissors2.py
File metadata and controls
74 lines (68 loc) · 2.1 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
70
71
72
73
74
'''Python Tutorial: Rock, Paper Scissors Game
Can be used for Water, Snake, Gun game also
# rock/paper/scissors/lizard/Spock...@Darrell Gregg: facebook
'''
import random
choices = ["Rock", "Paper", "Scissors", "Lizard", "Spock"]
wins = {
"Rock": "ScissorsLizard",
"Paper": "RockSpock",
"Scissors": "PaperLizard",
"Lizard": "PaperSpock",
"Spock": "ScissorsRock"
}
score = {"robo": 0, "human": 0}
def quitter():
print("\nQuitters never win!")
print("Score" + ("-" * 5))
print(f"🧍: {score['human']}, 🤖: {score['robo']}")
exit()
print("Let's play Rock Paper Scissors Lizard Spock!")
while True:
inp = input("Press 'R' for rules, 'P' to play, 'Q' to quit\n").lower()
if inp == "r":
print("\nRules:\n"
"rock crushes scissors\n"
"rock crushes lizard\n"
"paper covers rock\n"
"paper disproves Spock\n"
"scissors cuts paper\n"
"scissors decapitates lizard\n"
"lizard poisons Spock\n"
"lizard eats paper\n"
"Spock smashes scissors\n"
"Spock vaporizes rock\n")
continue
elif inp == "q":
quitter()
elif inp == "p":
break
"""
Begin gameplay code
"""
human = ""
while True:
inp = input("r, p, s, l, sp... Your guess, or quit: ").lower()
if inp == "q":
quitter()
if inp not in ["r", "p", "s", "l", "sp"]:
print("Invalid guess! Try again!")
continue
if inp == "sp":
human = "Spock"
else:
for i in choices:
if inp == i[0].lower():
human = i
robo = random.choice(choices)
print(f"🧍: {human} vs. 🤖: {robo}")
if human == robo:
print("Tie, no points!")
if robo in wins[human]:
print("You win a point!")
score["human"] += 1
elif human in wins[robo]:
print("The robot wins a point!")
score["robo"] += 1
print(f"🧍: {score['human']}, 🤖: {score['robo']}")
print()