forked from AnanyaDas162/Code-Collection-Hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakeGun Game
47 lines (43 loc) · 1.77 KB
/
SnakeGun Game
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
import random #it is for random input calling
def game(comp,you):
if comp== you: # jodi ami ar comp same di then tie tai none return
return None
elif comp=='s':# jodi comp snake aar ami water then snake water kheye nebe so i will loose so i have return false for this case but jodi ami gun niye ni then ami snake k destroy kore debo so i have returned true for that time
if you=='w':
return False
elif you=='g':
return True
elif comp=='w':
if you=='g':
return False
elif you=='s':
return True
elif comp=='g':
if you=='s':
return False
elif you=='w':
return True
while(1):
print("Comp turn:Snake(s) water(w) or Gun(g)")
randNo=random.randint(1,3)#by this computer will choose random any input from 1 to 3
if randNo==1:
comp='s'
elif randNo==2:
comp='w'
elif randNo==3:
comp='g'
print("\n Computer have shoosen now its your's Turn Buddy: \n")
you=input("\n Choose any one: Snake(s) water(w) or Gun(g)= \n")
a=game(comp,you)
print(f"computer chooses {comp}")# here i am using f string
print(f"You choose {you}")
if a== None:
print("\n The game is a tie")
elif a:
print(''' \n \t CONGRATULATION
BUDDY YOU HAVE WON THE MATCH
# # $ $ @ @ ''')
else:
print(" \n SORRY BRO \n YOU HAVE LOST ........ \n ALL THE BEST \n FOR NEXT TIME ")
#here in this game computer's turn will generated by random input by compiler
#your turn will be user input