-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (37 loc) · 1.08 KB
/
main.py
File metadata and controls
46 lines (37 loc) · 1.08 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
import random
def game_win(user, computer):
if user == computer:
return None
#Snake VS Water
if user == "s" and computer == "w":
return True
if user == "w" and computer == "w":
return False
#Water VS Gun
if user == "w" and computer == "g":
return True
if user == "g" and computer == "w":
return False
#Gun VS Snake
if user == "g" and computer == "s":
return True
if user == "s" and computer == "g":
return False
rand_no = random.randint(1,3) #random number - 1 or 2 or 3
print("Computer's Turn : Snake(s), Water(w), Gun(g) \nComputer Chose!")
if rand_no == 1:
computer = "s"
elif rand_no == 2:
computer = "w"
else:
computer = "g"
user = input("Your turn : Snake(s), Water(w), Gun(g) : ").lower()
result = game_win(user, computer) #Returns true if user wins, none for draw, false if you lose
print(f"\nYOU CHOSE : {user}")
print(f"\nCOMPUTER CHOSE : {computer}")
if result is None:
print("It's a draw!")
elif(result):
print("You WIN!")
else:
print("You LOSE!")