forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpygame.py
77 lines (57 loc) · 1.85 KB
/
pygame.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# author-slayking1965
"""
This is a game very similar to stone paper scissor
In this game :
if computer chooses snake and user chooses water, the snake will drink water and computer wins.
If computer chooses gun and user chooses water, the gun gets drown into water and user wins.
And so on for other cases
"""
import random
import time
choices = {"S": "Snake", "W": "Water", "G": "Gun"}
x = 0
com_win = 0
user_win = 0
match_draw = 0
print("Welcome to the Snake-Water-Gun Game\n")
print("I am Mr. Computer, We will play this game 10 times")
print("Whoever wins more matches will be the winner\n")
while x < 10:
print(f"Game No. {x+1}")
for key, value in choices.items():
print(f"Choose {key} for {value}")
com_choice = random.choice(list(choices.keys())).lower()
user_choice = input("\n----->").lower()
if user_choice == "s" and com_choice == "w":
com_win += 1
elif user_choice == "s" and com_choice == "g":
com_win += 1
elif user_choice == "w" and com_choice == "s":
user_win += 1
elif user_choice == "g" and com_choice == "s":
user_win += 1
elif user_choice == "g" and com_choice == "w":
com_win += 1
elif user_choice == "w" and com_choice == "g":
user_win += 1
elif user_choice == com_choice:
match_draw += 1
else:
print("\n\nYou entered wrong !!!!!!")
x = 0
print("Restarting the game")
print("")
time.sleep(1)
continue
x += 1
print("\n")
print("Here are final stats of the 10 matches : ")
print(f"Mr. Computer won : {com_win} matches")
print(f"You won : {user_win} matches")
print(f"Matches Drawn : {match_draw}")
if com_win > user_win:
print("\n-------Mr. Computer won-------")
elif com_win < user_win:
print("\n-----------You won-----------")
else:
print("\n----------Match Draw----------")