83% found this document useful (6 votes)
8K views25 pages

Snake Game 1 SRS Documentation PDF

The document describes a project report for a Snake Game project. It includes sections on introduction, literature survey, modules, system design, implementation, testing, and conclusion. The project aims to develop a basic console version of the classic Snake Game using Python and PyGame where the player uses arrow keys to move a snake and eat food to grow while avoiding hitting walls or its own body.

Uploaded by

Keerthan K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
83% found this document useful (6 votes)
8K views25 pages

Snake Game 1 SRS Documentation PDF

The document describes a project report for a Snake Game project. It includes sections on introduction, literature survey, modules, system design, implementation, testing, and conclusion. The project aims to develop a basic console version of the classic Snake Game using Python and PyGame where the player uses arrow keys to move a snake and eat food to grow while avoiding hitting walls or its own body.

Uploaded by

Keerthan K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

SNAKE GAME

SRS Project Report Submitted


In partial fulfillment of the requirements for the award of the degree of

Bachelor of Technology
in
Computer Science and Engineering
by

Name
18N31A0XXX
Under the esteemed Guidance of
Mrs. P Honey Diana
Assistant Professor

Department of Computer Science and Engineering


Malla Reddy College of Engineering & Technology
(Autonomous Institution- UGC, Govt. of India)

(Affiliated to JNTUH, Hyderabad, Approved by AICTE, NBA &NAAC with ‘A’ Grade)

Maisammaguda, Kompally, Dhulapally, Secunderabad – 500100


website: www.mrcet.ac.in
December(2020)

1
Malla Reddy College of Engineering & Technology
(Autonomous Institution- UGC, Govt. of India)

(Affiliated to JNTUH, Hyderabad, Approved by AICTE, NBA &NAAC with ‘A’ Grade)

Maisammaguda, Kompally, Dhulapally, Secunderabad – 500100


website: www.mrcet.ac.in

CERTIFICATE
This is the bonafide record of the project entitled “SNAKE GAME”, submitted by
Name(18N31A0XXX) of B.Tech in the partial fulfillment of the requirements for the degree
of Bachelor of Technology in Computer Science and Engineering, Department of CSE during
the year 2020-2021. The results embodied in this project report have not been submitted to
any other university or institute for the award of any degree or diploma.

Project Guide Head of the Department

Mrs. P Honey Diana Dr. D. Sujatha

Assistant Professor Professor

EXTERNAL EXAMINER

2
DECLARATION

I hereby declare that the project titled “SNAKE GAME” submitted to Malla Reddy College
of Engineering and Technology (UGC Autonomous), affiliated to Jawaharlal Nehru
Technological University Hyderabad (JNTUH) for the award of the degree of Bachelor of
Technology in Computer Science and Engineering is a result of original research carried-out
in this thesis. It is further declared that the project report or any part thereof has not been
previously submitted to any University or Institute for the award of degree or diploma.

Name

18N31A0XXX

3
ACKNOWLEDGEMENT

Presentation inspiration and motivation have always played a key role in the success of any
venture

I feel myself honored and privileged to place my warm salutation to our college Malla Reddy
College of Engineering and Technology and our Director Dr. VSK Reddy who gave us the
opportunity to have experience in engineering and profound technical knowledge.

I would like to express my gratitude to Dr. S Srinivas Rao, Principal, Malla Reddy College
of Engineering and Technology for his constant support and motivation.

I express my heartiest thanks to our Head of the Department Dr. D. Sujatha, Computer
Science and Engineering for encouraging us in every aspect of our project and helping us
realize our full potential.

I pay my deep sense of gratitude to Mrs. P Honey Diana Assistant Professor and Project
Coordinator to encourage me to the highest peak and to provide me the opportunity to prepare
the project. I am extremely grateful to her valuable suggestions and unflinching co-operation
throughout project work.

I am immensely obliged to my friends for their elevating inspiration, encouraging guidance


and kind supervision in the completion of my project

Last, but not least, my parents are also an important inspiration for me. So with due
regards, I express my gratitude to them.

With regards and gratitude,

Name
18N31A0XXX

4
ABSTRACT

KEY WORDS: Snake Game, Py-Game

The Project entitled ‘Snake Game’ is a simple console application without graphics. In this project,
you can play the popular “Snake Game” just like you played it elsewhere. You have to use the up,
down, right or left arrows to move the snake.

Foods are provided at the several co-ordinates of the screen for the snake to eat. Every time the snake
eats the food, its length will by increased by one element along with the score.

I have used Python as Programming language for writing the code for the project and Jupyter
Notebook for writing the programs. Operating system used Windows 10.

Software Requirements are:


• Python
• Jupyter Notebook
• Operating System used Windows 10.

5
TABLE OF CONTENTS

CONTENTS PAGENO

1. INTRODUCTION TO PROJECT 8

2. LITERATURE SURVEY 9

3. MODULES 10

4.SYSTEM DESIGN 11-15

4.1 SOFTWARE DESIGN 11-12

4.2 FUNCTIONAL REQUIREMENTS 12

4.3 NON-FUNCTIONAL REQUIREMENTS 12-13

4.4 SOFTWARE REQUIREMENT SPECIFICATION 13-14

4.4.1 WHAT IS SRS? 13

4.4.1.1 Problem/Requirement Analysis 14

4.4.1.2 Requirement Specification 14

4.4.1.3 Role of SRS 14

4.4.1.4 Scope 14

4.5 HARDWARE AND SOFTWARE REQUIREMENTS 14-15

4.5.1 Software Requirements 14

4.5.2 Hardware Requirements 15

5.IMPLEMENTATION 16-20

6
5.1 PYTHON 16-17

5.2 PY-GAME 18

5.3 FUNCTION DESCRIPTION 19

5.4 IMPLEMENTATION STEPS 20

5.5 WORKING ALGORITHM 20

6.TESTING 21-23

6.1 SOFTWARE TESTING 21

6.1.1 Testing objectives 21

6.2 TEST CASE DESIGN 21

6.2.1 White box testing 21

6.2.2 Black box testing 21

6.2.3 unit testing 22

6.2.4 Integration testing 22

22
6.2.5 Validation testing
22
6.2.6 System testing
22-23
6.3 TEST CASES
24
7.CONCLUSION AND FUTURE ENHANCEMENT
25
8.BIBLIOGRAPHY

7
Chapter 1: INTRODUCTION

Playing games is fun and exciting it gives us relief from stress and unwind from our stressful works.
Many of us spend our vacant time or others that use most of their time in playing and exploring new
games. Today, with the rapid development of technology we have, games that are rising up together
with it. Nowadays with the technology we have many games that are developing for computer most
specifically for windows. With the high technology equipped with these computers,computer games
become robust and attract many people to buy or have this gadget for them to experience what’s
inside it which makes it a trend for the new generation of gadget.

Snake game is a computer action game; whose goal is to control a snake to move and collect food
in a map. It has been around since the earliest days of home computing and has re-emerged in
recent years on mobile phones.

It isn’t the world’s greatest game, but it does give you an idea of what you can achieve with a
simple python program, and perhaps the basis by which to extend the principles and create more
interesting games on your own.

To move the snake, use ‘up arrow’ for up, ‘down arrow’ for down, ‘left arrow’ for left and ‘right
arrow’ for right. Press ‘Q’ to exit the game at any time, press ‘C’ to continue the game.

The aim of the game is to collect the dots (food) and avoid the obstacles (crosses borders). As you
collect the food, the snake gets longer. The score also increases. There is no concept of lives. Once
you hit an obstacle, that’s it, game over.

8
Chapter 2: LITERATURE SURVEY

The history of the Snake game goes back to the 1970's, the concept originated in the 1976 arcade
game Blockade, and its simplicity has led to many implementations. However, it was the 1980's
when the game took on the look that we will be using. It was sold under numerous names and
many platforms but probably gained widespread recognition when it was shipped as standard on
Nokia mobile phones in the late 1990's. The first published Nokia, for monochrome phones. It
was programmed in 1997 by Taneli Armanto of Nokia and introduced on the Nokia 6110.

The game involves controlling a single block or snakehead by turning only left or right by ninety
degrees until you manage to eat an block. When you get the block, the Snake grows an extra
block or body segment.

If, or rather when, the snake bumps into the edge of the screen or accidentally eats himself the
game is over. The more blocks the snake eats the higher the score .

9
Chapter 3: MODULES

pygame

• Py game is a cross-platform set of python modules designed for writing video games.
It includes computer graphics and sound libraries designed to be used with the Python
Programming language.

• To install the library, you can use pip installer from the command line:

pip install pygame

import pygame

Python time module


• Python has a module named time to handle time-related tasks. To use functions defined in
the module, we need to import the module first. Here's how:

import time

Python random module

• Python has a built-in module that you can use to make random numbers.

import random

10
Chapter 4: SYSTEM DESIGN
Chapter 3: SY
To create a Snake game that allows users to control the movement of a snake on a screen, to get points
for eating food and avoiding running into the walls or the growing tail of the snake itself. In this
problem, we want to write a game where a graphical representation of a snake moves across the
screen. When it encounters a piece of food, the snake grows longer and we gain a point. If it hits the
wall we die.
To write this program we are going to need:
● A way of representing the snake
● A way of representing the food
● A way to display the score,
● a way for our instructions to reach the snake,
● and a way to know when we’ve run into something and died
Our system is going to involve working with both hardware and software, and so we will need to
understand what we have available in hardware that can assist us.
If we build our software so that the snake is controlled by directional arrows on the keyboard.
Now that understand how our hardware will work in the design of our system, let’s move on to starting
the design of our software system.

4.1 SOFTWARE DESIGN

• We are going to use an object-oriented approach and provide some detail here.
• We have to think about the Classes that we want to build, with the associated variables and
functions that will make sense for the development.
• Let's start by looking at the snake itself, the hero of the game. The snake has a location on
the screen, and contains multiple visual elements, as it can grow, and the snake's head is
connected to the rest of the snake and the snake's body follows it around the screen. If the
snake "eats" food, it grows.
• The snake moves in a very precise way. Based on what the user types, the snake will move
in a given direction. Every time the snake moves, the head will go in the new direction, and
every piece of the snake will move up, by occupying the space that was formerly occupied
by the piece in front of it.
• To grow in size, the snake has to eat food. How can we show the snake eating? The
simplest answer is that if the head of the snake and the food are in the same place, we

11
consider that the snake eats the food. This means that we have to know where the food is.
When it’s eaten, it disappears, the snake grows, and the food shows up somewhere else.
• But we also wanted to show a score, so we need a variable to keep track of that as well. In
this case, we’ll create a Scoreboard class where we can increase the counter value and
display it

4.2 FUNCTIONAL REQUIREMENTS


Here are the requirements (functional requirements) for how the snake moves.

1. The snake must appear to move around the screen

2. The snake must turn in response to user input

3. The snake will increase in length if it eats food

4. The snake will die if it runs into the walls

5. The snake never stops moving

4.3 NON-FUNCTIONAL REQUIREMENTS


The primary features of IT projects involve implementing like an application, a piece of infrastructure,

a patch.

In this specific context functional requirements tells us about what project does when

interacted, whereas non-functional requirements describe about the bounds of performance should be.

I.Robustness:

Robustness is nothing but its ability that it can tolerate the affects of system functional body. And it

can also be defined as its systems ability that it can withstand to change without transforming its

initial stable configuration.

12
II.Reliability:

The system is trustworthy and it is consistently good in performance. It can also be stated as the

system performs the function without any failure under certain conditions and specified period of

time.

III.Availability:

The system is available 24*7. Availability and Reliability are directly proportional as reliability

increase availability also increases. The user can have access to the system all the time.

IV.Reusability:

The system can be used any number of times by the specific user. And the reusability is consistent,

adaptable and stable.

V.Effectiveness:

The algorithm is capable of producing desired result or it has the ability to provide better results.

4.4 SOFTWARE REQUIREMENT SPECIFICATION


4.4.1What is SRS?
Software Requirement Specification (SRS) is the starting point of the software developing activity.
As system grew more complex it became evident that the goal of the entire system cannot be easily
comprehended. Hence the need for the requirement phase arose. The software project is initiated by
the client needs. The SRS is the means of translating the ideas of the minds of clients (the input)

13
into a formal document (the output of the requirement phase.) The SRS phase consists of two basic
activities:

4.4.1.1 Problem/Requirement Analysis:


The process is order and more nebulous of the two, deals with understand the problem, the goal and
constraints.

4.4.1.2 Requirement Specification:


Here, the focus is on specifying what has been found giving analysis such as representation,
specification languages and tools, and checking the specifications are addressed during this activity.
The Requirement phase terminates with the production of the validate SRS document. Producing
the SRS document is the basic goal of this phase.

4.4.1.3 Role of SRS:


The purpose of the Software Requirement Specification is to reduce the communication gap
between the clients and the developers. Software Requirement Specification is the medium through
which the client and user needs are accurately specified. It forms the basis of software development.
A good SRS should satisfy all the parties involved in the system.

4.4.1.4 Scope:
This document is the only one that describes the requirements of the system. It is meant for the use
by the developers, and will also be the basis for validating the final delivered system. Any changes
made to the requirements in the future will have to go through a formal change approval process.
The developer is responsible for asking for clarifications, where necessary, and will not make any
alterations without the permission of the client.

4.5 HARDWARE AND SOFTWARE REQUIREMENTS


4.5.1 Software Requirements
The development and deployment of the application requires the following general and specific
minimum requirements for software:

• Programming Language Translators - Python 3.8


• IDE- Jupyter Notebook
• Operating System used Windows 10.

14
4.5.2 HARDWARE REQUIREMENTS

The development and deployment of the application requires the following general and specific
minimum requirements for hardware:

• Processor- (32-bit or 64-bit)


• RAM (4 GB)

15
CHAPTER 5 : IMPLEMENTATION

5.1 PYTHON
Python is an object-oriented, high level language, interpreted, dynamic and multipurpose
programming language.

Python is easy to learn yet powerful and versatile scripting language which makes it attractive for
Application Development.

Python's syntax and dynamic typing with its interpreted nature, make it an ideal language for
scripting and rapid application development in many areas.

Python supports multiple programming pattern, including object oriented programming, imperative
and functional programming or procedural styles.

Python is not intended to work on special area such as web programming. That is why it is known
as multipurpose because it can be used with web, enterprise, 3D CAD etc.

We don't need to use data types to declare variable because it is dynamically typed so we can write
a=10 to declare an integer value in a variable.

Python makes the development and debugging fast because there is no compilation step included in
python development and edit-test-debug cycle is very fast.

Python History
• Python laid its foundation in the late 1980s.
• The implementation of Python was started in the December 1989 by Guido Van Rossum at
CWI in Netherland.
• ABC programming language is said to be the predecessor of Python language which was
capable of Exception Handling and interfacing with Amoeba Operating System.
• Python is influenced by programming languages like:
• ABC language
• Modula-3

16
Python Versions
Python programming language is being updated regularly with new features and support. There are
a lot of updation in python versions, started from 1994 to current date.

A list of python versions with its date is given below.

Python Version Released Date


Python 1.0 January 1994

Python 1.5 December 31, 1997

Python 1.6 September 5, 2000

Python 2.0 October 16, 2000

Python 2.1 April 17, 2001

Python 2.2 December 21, 2001

Python 2.3 July 29, 2003

Python 2.4 November 30, 2004

Python 2.5 September 19, 2006

Python 2.6 October 1, 2008

Python 2.7 July 3, 2010

Python 3.0 December 3, 2008

Python 3.1 June 27, 2009

Python 3.2 February 20, 2011

Python 3.3 September 29, 2012

17
5.2 PY-GAME

Python is the most popular programming language or nothing wrong to say that it is the next-
generation programming language. In every emerging field in computer science, Python makes its
presence actively. Python has vast libraries for various fields such as Machine Learning (Numpy,
Pandas, Matplotlib), Artificial intelligence (Pytorch, TensorFlow), and Game development
(Pygame,Pyglet).

Game programming is very rewarding nowadays and it can also be used in advertising and as a
teaching tool too. Game development includes mathematics, logic, physics, AI, and much more and it
can be amazingly fun. In python, game programming is done in pygame and it is one of the best
modules for doing so.

o Pygame is a cross-platform set of Python modules which is used to create video games.
o It consists of computer graphics and sound libraries designed to be used with the Python
programming language.
o Pygame was officially written by Pete Shinners to replace PySDL.
o Pygame is suitable to create client-side applications that can be potentially wrapped in a
standalone executable.

Installing pygame:
The first thing you will need to do in order to create games using Pygame is to install it on your
systems. To do that, you can simply use the following command:

pip install pygame

18
5.3 FUNCTION DESCRIPTION

Once that is done, just import Pygame and start our game development. Before moving on, take a
look at the Pygame functions that have been used in this Snake Game along with their descriptions.

Function Description
init() Initializes all of the imported Pygame modules (returns a
tuple indicating success and failure of initializations)

display.set_mode() Takes a tuple or a list as its parameter to create a surface


(tuple preferred)

update() Updates the screen

quit() Used to uninitialize everything

set_caption() Will set the caption text on the top of the display screen

event.get() Returns list of all events

Surface.fill() Will fill the surface with a solid color

time.Clock() Helps track time time

font.SysFont() Will create a Pygame font from the System font resources

19
5.4 IMPLEMENTATION STEPS
1. Installing pygame
2. Create the screen
3. Create the Snake
4. Moving the Snake
5. Game over when snake hits the boundaries
6. Adding the Food
7. Increasing the length of the snake
8. Displaying the score

5.5 WORKING ALGORITHM

Let's look at how a program to run the whole game might look:

1. Draw the playing area with bounding rectangle, set the counter to zero and display it.

2. Draw the snake in a starting position.

3. Draw the food in a starting location.

4. On user input, change snake direction.

5. Move the snake one move

6. If the snake is over food, eat it, increase the score, grow, move the food,

7. else if the snake is over in a wall, die.

8. Go back to 4.

9. Until the snake die

20
CHAPTER 6: TESTING

6.1 SOFTWARE TESTING


Software testing is a critical element of software quality assurance and represents the ultimate review
of specification, design and code generation.
6.1.1 Testing Objectives
• To ensure that during operation the system will perform as per specification.
• TO make sure that system meets the user requirements during operation
• To make sure that during the operation, incorrect input, processing and output will be
detected
• To see that when correct inputs are fed to the system the outputs are correct
• To verify that the controls incorporated in the same system as intended
• Testing is a process of executing a program with the intent of finding an error
• A good test case is one that has a high probability of finding an as yet undiscovered
error.
The software developed has been tested successfully using the following testing strategies and
any errors that are encountered are corrected and again the part of the program or the procedure or
function is put to testing until all the errors are removed. A successful test is one that uncovers an as
yet undiscovered error.

Note that the result of the system testing will prove that the system is working correctly. It
will give confidence to system designer, users of the system, prevent frustration during
implementation process etc.,

6.2 TEST CASE DESIGN:

6.2.1 White box testing


White box testing is a testing case design method that uses the control structure of the
procedure design to derive test cases. All independents path in a module are exercised at least once,
all logical decisions are exercised at once, execute all loops at boundaries and within their operational
bounds exercise internal data structure to ensure their validity. Here the customer is given three
chances to enter a valid choice out of the given menu. After which the control exits the current menu.

6.2.2 Black Box Testing


Black Box Testing attempts to find errors in following areas or categories, incorrect or missing
functions, interface error, errors in data structures, performance error and initialization and
termination error. Here all the input data must match the data type to become a valid entry.

21
6.2.3 Unit Testing:

Unit testing is essentially for the verification of the code produced during the coding phase
and the goal is test the internal logic of the module/program. In the Generic code project, the unit
testing is done during coding phase of data entry forms whether the functions are working properly
or not. In this phase all the drivers are tested they are rightly connected or not.

6.2.4 Integration Testing:

All the tested modules are combined into sub systems, which are then tested. The goal is to
see if the modules are properly integrated, and the emphasis being on the testing interfaces between
the modules. In the generic code integration testing is done mainly on table creation module and
insertion module.

6.2.5 Validation Testing


This testing concentrates on confirming that the software is error-free in all respects. All the
specified validations are verified and the software is subjected to hard-core testing. It also aims at
determining the degree of deviation that exists in the software designed from the specification; they
are listed out and are corrected.

6.2.6 System Testing


This testing is a series of different tests whose primary is to fully exercise the computer-based
system. This involves:

• Implementing the system in a simulated production environment and testing it.


• Introducing errors and testing for error handling.

6.3 TEST CASES

How can we test a full Snake game and, assuming it passes that stage, how can we playtest that?

The functional requirements that the we developed turn, almost immediately,

To display the snake, the first thing we want to do is to make sure that we can draw the snake and
move it around on the screen. So our testing for correct function will be:

1. Can I display the snake's head on the screen?

2. Will it move around as I want it to using keyboard control?

22
3. Is it displaying correctly?

4. Is the body moving correctly?

If we identify an error in the snake, because it's a Class, we will go into the Snake class and fix it
there. However, because we've written the Food and Scoreboard as separate classes, whatever we
do in the Snake class shouldn't break anything in there, unless we accidentally change the code
without noticing. The next step for the snake will be checking what happens when the head is
detected as colliding with something. Does it grow when it eats food? Does it die when it hits a wall
or itself? We'd then continue to test the program until we've tested all of the individual elements and
their interactions together.

One useful test case is to see if everything is being drawn where you expect. Because we aren't
using all the screen, it's possible to draw the food or the snake so that it overlaps the black rectangle
that's the boundary. Has the programmer put the correct limits on the ranges where the snake and
the food can appear?

Testing the non-functional requirements often falls into the realm of playability

Many snake games increase the speed of the snake as it gets longer, increasing the difficulty even
further. This increased movement speed gives a sense of urgency and can be a way to engage
players with the snake. But make it too fast and it becomes unplayable

23
CHAPTER 7: CONCLUSIONS

• The project in python programming of Snake Game is a simple console application with
very simple graphics. In this project, you can play the popular “Snake Game” just like you
played it elsewhere. You have to use the up, down, right, or left arrows to move the snake.
• Foods are provided at the several co-ordinates of the screen for the snake to eat. Every time
the snake eats the food, its length will be increased by one element along with the score.
• It isn’t the world’s greatest game, but it does give you an idea of what you can achieve with
a relatively simple python programming, and perhaps the basis by which to extend the
principles and create more interesting games on your own.

Future Scope:
In this project, I have used simple application, this project will be able to implement in future after
making some changes and modifications as I made this project at low level. The modifications that
can be done in this project are:

1. It can be made with good graphics.


2. We can add more options like Top scores and Player Profile.
3. We can add multiplayer option.

24
CHAPTER 8: BIBLIOGRAPHY

WEBSITES
• https://www.edureka.co/blog/snake-game-with-pygame/
• https://pypi.org/project/pygame/
• https://www.educba.com/python-pygame/
• https://www.w3schools.com/python/module_random.asp
• https://www.programiz.com/python-programming/time

25

You might also like