Snake Water Gun Game in Python with Source Code

Snake Water Gun Game in Python is a simple game that can be played. The rules say that each player must use one hand to make one of three shapes at an agreed-upon time.

The person who plays the strongest “object” is the winner of the game.

Also read: How To Make Tic Tac Toe In Python

Snake Water Gun Game Project Software Information

Project Name:Snake Water Gun Game in Python
Abstract:Snake Water Gun Game in Python is a hand game where the player picks one of three shapes at random: snake, water, or gun.
Language Used:Python Programming Language
Python Version:2.x or 3.x
Database:None
Type:Console Based
Developer:Angel Jude Suarez
Snake Water Gun Game with Source Code

About Snake Water Gun Game Project

Snake Water Gun is a well-known two-player game that many people like to play. It’s a hand game where the player picks one of three shapes at random: snake, water, or gun.

Here, we’re going to use Python to make this game work.

This Python project is to make a single-player game that is played against the computer.

How To Play Snake Water Gun Game?

This is the same as “rock, paper, scissors.” Both players should keep their movements at the same time. The snake drinks the water, and the gun kills the snake, but the gun doesn’t do anything to the water.

Instructions:

Your task for today is to make your first Python game, “Snake Water Gun.”

Most of you must already know about the game. Still, I will give you a brief description.

This is a two-player game where each person chooses one object. As we know, there are three things: a snake, water, and a gun.

Rules of the Game:

Following are the rules of Snake Water Gun Games.

  • Snake vs. Water: Snake drinks water, so it wins.
  • Water vs Gun: The gun will sink in water, so it’s a point for water.
  • Snake vs. Gun: The gun will win because it will kill the snake.
  • If both players choose the same object, the game will end in a tie.

How To Make a Snake Water Gun Game in Python with Source Code

Before you start creating a Snake Water Gun Game in Python, make sure that you have already Pycharm IDE and Installed Python on your Computer.

Steps on how To Make a Snake Water Gun Game in Python:

Time needed: 5 minutes

How To Make a Snake Water Gun Game in Python with Source Code

  • Step 1: Open PyCharm IDE and Create New Project

    First, Open PyCharm IDE, Select Create New Project, and Name it.

  • Step 2: Create Python File

    Next, just right-click your Project Folder, Select New, and Select Python File.

  • Step 3: Python File Name

    Next, after creating a Python File you are required to name the file.

  • Step 4: Actual Code

    Finally, just copy the complete source code given below and paste it into your Python File.

Code Explanations

Here are the step-by-step explanations in each line of code on how to create a Snake Water Gun Game.

1. Import Libraries

Explanation:

The line of code given below explained that we want to import “random” as the game Libraries.

Code:

# Import random library

import random

2. Number of Rounds

Explanation:

The line of code given below explained that we want to input the number of rounds in playing the game.

Code:

# Input no. of rounds

n = int(input('Enter number of rounds: '))

3. Game Options

Explanation:

In the line of code given below explained that we want to select what option we want is either Snake (s), Water (w) or Gun (s).

Code:

# List containing Snake(s), Water(w), Gun(g)

options = ['s', 'w', 'g']

4. Declaring Variables

Explanation:

The line of code given below explained for declaring Variables and their Value.

Code:

#Declaring Variables

# Round numbers
rounds = 1

# Count of computer wins
comp_win = 0

# Count of player wins
user_win = 0

5. Conditions Based On The Selected Game Option

Explanation:

The line of code given below explained the step-by-step condition based on the selected option given by the system.

Code:

while rounds <= n:

	# Display round
	print(f"Round :{rounds}\nSnake - 's'\nWater - 'w'\nGun - 'g'")

	# Exception handling
	try:
		player = input("Choose your option: ")
	except EOFError as e:
		print(e)

	# Control of bad inputs
	if player != 's' and player != 'w' and player != 'g':
		print("Invalid input, try again\n")
		continue

	# random.choice() will randomly choose
	# item from list- options
	computer = random.choice(options)

	# Conditions based on the game rule
	if computer == 's':
		if player == 'w':
			comp_win += 1
		elif player == 'g':
			user_win += 1

	elif computer == 'w':
		if player == 'g':
			comp_win += 1
		elif player == 's':
			user_win += 1

	elif computer == 'g':
		if player == 's':
			comp_win += 1
		elif player == 'w':
			user_win += 1

6. Announced Winner Based on Every Selected Options

Explanation:

The line of code given below explained for announcing the winner based on every selected option given by the system.

Code:

# Announce winner of every round

	if user_win > comp_win:
		print(f"You Won round {rounds}\n")
	elif comp_win > user_win:
		print(f"Computer Won round {rounds}\n")
	else:
		print("Draw!!\n")

	rounds += 1

7. Final Winner Based on The Number of Won’s

Explanation:

In the line of code given below is the final process of the system to declare who wins based on the number of won.

Code:

# Final winner based on the number of wons

if user_win > comp_win:
	print("Congratulations!! You Won")
elif comp_win > user_win:
	print("You lose!!")
else:
	print("Match Draw!!")

In Summary

Hooray! we have completed the step-by-step process on How To Make a Snake Water Gun Game in Python with Source Code and explanations are given. I hope you learned a lot in developing a simple game for Snake Water Gun Game Project.

Frequently Asked Questions

How does the Python Snake Water Gun game decide a winner?

It is a 3-choice game similar to Rock Paper Scissors. The rules: snake drinks water (snake beats water), water douses gun (water beats gun), gun shoots snake (gun beats snake). You pick one, computer picks randomly. Same choices tie. The game runs a configurable number of rounds (usually 10) and tallies total wins per player at the end.

What Python version do I need to run this game?

Python 3.8 or newer works. We recommend Python 3.11 or 3.12 because Pygame ships pre-built wheels for those versions (faster pip install, no compilation errors). Python 3.13 may need a slightly older Pygame release because some wheels lag the latest CPython. Verify your version with python –version on Windows or python3 –version on Mac/Linux.

How do I install Pygame for this project?

Run pip install pygame in your terminal (Windows: open Command Prompt, Mac/Linux: open Terminal). On Windows, if pip is not recognized, try python -m pip install pygame instead. On Linux, you may need sudo apt install python3-pygame if pip fails. Verify with python -c “import pygame; print(pygame.version.ver)”.

Can I use this Python game as my BSIT capstone project?

On its own, no, most Philippine BSIT panels expect a full system with users, data, reports, and a real-world problem. A single Pygame game is too narrow for capstone scope. BUT, you can use this game as ONE module inside a larger capstone (e.g. a gamified learning system, a math practice tool for elementary students with this game as the reward layer, or an arcade-style POS for an internet cafe). Pair the game with a Django backend, a database, and analytics for a defensible capstone.

Can I package this game as a standalone .exe to distribute?

Yes, use PyInstaller. Run pip install pyinstaller then pyinstaller –onefile –windowed your_game.py from the project folder. PyInstaller bundles Python and Pygame into a single .exe (Windows) or .app (Mac) that runs without Python installed on the target machine. Include asset files (images, sounds) with –add-data “assets;assets”. Output goes to the dist/ folder.

Where do I get help if the game does not run?

Check the top 3 most common failures: (1) Pygame is not installed correctly, re-run pip install pygame. (2) The game cannot find an asset file (image/sound), make sure you run python from the project folder so relative paths resolve. (3) Wrong Python version, this code expects Python 3.8+; older Python 2.x or 3.6 raises syntax errors. If you still hit a wall, drop a comment on this article with the exact error message, our team monitors comments daily.

Glay Eliver

Programmer & Technical Writer at PIES IT Solution

Glay Eliver is a programmer and writer at PIES IT Solution, author of over 600 tutorials at itsourcecode.com. Specializes in JavaScript tutorials, Microsoft Office how-tos (Excel, Word, PowerPoint), and Python error debugging covering ImportError, TypeError, AttributeError, ModuleNotFoundError, and JavaScript ReferenceError. Authored several of the site’s highest-traffic Excel and MS Office reference articles.

Expertise: JavaScript · MS Excel · MS Word · MS PowerPoint · Python · Python ImportError · Python TypeError · Python AttributeError · ModuleNotFoundError · JavaScript ReferenceError · Pygame  · View all posts by Glay Eliver →

Leave a Comment