File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ import random
3+
4+ print ("Player no.1- choose snake(1) , water(2) or gun(3)" )
5+
6+ comp = random .randint (1 ,3 )
7+
8+ you = input ("Player no.2- choose snake(s) , water(w) or gun(g)" )
9+ if comp == 1 :
10+ comp = "s"
11+ elif comp == 2 :
12+ comp = "w"
13+ elif comp == 3 :
14+ comp = "g"
15+ def gamewin (comp ,you ):
16+
17+ # by chance if both you and comp choose same thing
18+ if comp == you :
19+ return None
20+ # check for all posibilities when comp choose snake(s)
21+ if comp == "s" :
22+ if you == "w" :
23+ return False
24+ elif you == "g" :
25+ return True
26+ # if computer has snake and you choose water then you will loose
27+ # so it will return false and if you have gun then return true
28+ # this means you win
29+
30+ # check for all posibilities when comp choose water(w)
31+ elif comp == "w" :
32+ if you == "g" :
33+ return False
34+ elif you == "s" :
35+ return True
36+
37+ # check for all posibilities when comp choose gun(g)
38+ elif comp == "g" :
39+ if you == "s" :
40+ return False
41+ elif you == "w" :
42+ return True
43+
44+ s = gamewin (comp ,you )
45+
46+ print ("the vlaue choosen by computer" ,comp )
47+ print ("the vlaue choosen by you" ,you )
48+ # this will print what computer and you have choosen
49+ # ( in case you wnated to know)
50+ if s == None :
51+ print (" the game has tie!!!!" )
52+ elif s == True :
53+ print ("You win the game!!" )
54+ else :
55+ print ("You loose the game !!" )
You can’t perform that action at this time.
0 commit comments