Snake Water Gun Game using Python
Hey Internet Programmer, Today we are gonna build Snake Water Gun Game using Python. Snake Water Gun is one of the famous two-player game played by many people. It is a hand game in which the player randomly chooses any of the three forms i.e. snake, water, and gun. Here, we are going to implement this game using python.
This python project is to build a game for a single player that plays with the computer.
Code
# snake water gun
# rule
# Snake vs. Water: Snake drinks the water hence wins.
# Water vs. Gun: The gun will drown in water, hence a point for water
# Gun vs. Snake: Gun will kill the snake and win.
# play 10 time
import random
print(" ---------------")
print("|Snake Water Gun|")
print(" ---------------")
listShape = ["S", "W", "G"]
userScore = 0
computerScore = 0
i = 1
while i <= 10:
computerShape = str(random.choice(listShape))
userShape = input("Enter Snake, Water Gun (key: S,W,G): ").upper()
if userShape == computerShape:
print("Tie You Both Entered Same")
elif computerShape == "W" and userShape == "S":
print(("Computer Enter", computerShape))
print("👉 Snake Drink Water")
userScore += 1
elif computerShape == "S" and userShape == "W":
print(("Computer Enter", computerShape))
print("👉 Snake Drink Water")
computerScore += 1
elif computerShape == "G" and userShape == "W":
print(("Computer Enter", computerShape))
print("👉 Gun Drowning in Water ")
userScore += 1
elif computerShape == "W" and userShape == "G":
print(("Computer Enter", computerShape))
print("👉 Gun Drowning in Water ")
computerScore += 1
elif computerShape == "S" and userShape == "G":
print(("Computer Enter", computerShape))
print("👉 Gun Shoot the Snake")
userScore += 1
elif computerShape == "G" and userShape == "S":
print(("Computer Enter", computerShape))
print("👉 Gun Shoot the Snake")
computerScore += 1
else:
print(":(")
print("\n\t******ScoreBoard******")
print(f"\t You: {userScore} | Computer: {computerScore}")
print("\t**********************")
print(f"Game No:[{i}]")
print("========================================================")
i += 1
print("\n\n##### Game Khatam Paisa Hajam #####")
print("*******************************************")
if userScore < computerScore:
print(
f"😭 Sorry You lose the game 😭\n computer win the "
f"game with {computerScore} score"
)
elif userScore == computerScore:
print((Fore.CYAN, "😅 Game is Tie Play Again 😅"))
else:
print(f"😄 You Win the Game with {userScore} score 😄")
Output
---------------
|Snake Water Gun|
---------------
Enter Snake, Water Gun (key: S,W,G): g
('Computer Enter', 'W')
👉 Gun Drowning in Water
******ScoreBoard******
You: 0 | Computer: 1
**********************
Game No:[1]
========================================================
Enter Snake, Water Gun (key: S,W,G): w
('Computer Enter', 'G')
👉 Gun Drowning in Water
******ScoreBoard******
You: 1 | Computer: 1
**********************
Game No:[2]
========================================================
Enter Snake, Water Gun (key: S,W,G): w
('Computer Enter', 'G')
👉 Gun Drowning in Water
******ScoreBoard******
You: 2 | Computer: 1
**********************
Game No:[3]
========================================================
Enter Snake, Water Gun (key: S,W,G): g
('Computer Enter', 'S')
👉 Gun Shoot the Snake
******ScoreBoard******
You: 3 | Computer: 1
**********************
Game No:[4]
========================================================
Enter Snake, Water Gun (key: S,W,G): w
('Computer Enter', 'S')
👉 Snake Drink Water
******ScoreBoard******
You: 3 | Computer: 2
**********************
Game No:[5]
========================================================
Enter Snake, Water Gun (key: S,W,G): g
('Computer Enter', 'S')
👉 Gun Shoot the Snake
******ScoreBoard******
You: 4 | Computer: 2
**********************
Game No:[6]
========================================================
Enter Snake, Water Gun (key: S,W,G): w
('Computer Enter', 'G')
👉 Gun Drowning in Water
******ScoreBoard******
You: 5 | Computer: 2
**********************
Game No:[7]
========================================================
Enter Snake, Water Gun (key: S,W,G): s
('Computer Enter', 'W')
👉 Snake Drink Water
******ScoreBoard******
You: 6 | Computer: 2
**********************
Game No:[8]
========================================================
Enter Snake, Water Gun (key: S,W,G): w
('Computer Enter', 'S')
👉 Snake Drink Water
******ScoreBoard******
You: 6 | Computer: 3
**********************
Game No:[9]
========================================================
Enter Snake, Water Gun (key: S,W,G): s
Tie You Both Entered Same
******ScoreBoard******
You: 6 | Computer: 3
**********************
Game No:[10]
========================================================
##### Game Khatam Paisa Hajam #####
*******************************************
😄 You Win the Game with 6 score 😄
Share it with your friends. Happy Coding :)
Other python stuff,