-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from Yuktikashyap/main
Snake, Water and Gun Pyhton Project
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
import random | ||
|
||
print("Player no.1- choose snake(1) , water(2) or gun(3)") | ||
|
||
comp = random.randint(1,3) | ||
|
||
you = input("Player no.2- choose snake(s) , water(w) or gun(g)") | ||
if comp == 1: | ||
comp = "s" | ||
elif comp == 2: | ||
comp = "w" | ||
elif comp == 3: | ||
comp = "g" | ||
def gamewin(comp,you): | ||
|
||
# by chance if both you and comp choose same thing | ||
if comp == you: | ||
return None | ||
# check for all posibilities when comp choose snake(s) | ||
if comp=="s": | ||
if you == "w": | ||
return False | ||
elif you == "g": | ||
return True | ||
# if computer has snake and you choose water then you will loose | ||
# so it will return false and if you have gun then return true | ||
# this means you win | ||
|
||
# check for all posibilities when comp choose water(w) | ||
elif comp=="w": | ||
if you == "g": | ||
return False | ||
elif you == "s": | ||
return True | ||
|
||
# check for all posibilities when comp choose gun(g) | ||
elif comp=="g": | ||
if you == "s": | ||
return False | ||
elif you == "w": | ||
return True | ||
|
||
s = gamewin(comp,you) | ||
|
||
print("the vlaue choosen by computer",comp) | ||
print("the vlaue choosen by you",you) | ||
# this will print what computer and you have choosen | ||
# ( in case you wnated to know) | ||
if s == None: | ||
print(" the game has tie!!!!") | ||
elif s == True: | ||
print("You win the game!!") | ||
else : | ||
print("You loose the game !!") |