CGMT Report AB
CGMT Report AB
ON
“Snake Game”
In partial fulfillment
“Bachelor of Technology”
April 2023
1|Page
STUDENT DECLARATION
I declare that my 6th semester report entitled ‘Snake Game’ is my own work
I further declare that to the best of our knowledge the report for B.tech 6 th semester
does not contain part of the work which has submitted for the award of B.tech degree
(Assistant professor)
2|Page
ACKNOWLEDGEMENT
Working in a good environment and motivation enhance the quality of the work and I
get it from my college through our CGMT project .
I have been permitted to take this golden opportunity under the expert guidance of
Ms. Charu Upadhyay from SGVU , Jaipur. I am heartily thankful to her to make
complete my project successfully. She has given us her full experience and extra
knowledge in practical field.
I am also thankful to my head of department Mr. Sohit Agarwal and all CEIT staff to
guide us.
Finally, we think all the people who had directly or indirectly help as to complete our
project.
Student name:
Ayushi Bhardwaj
3|Page
CERTIFICATE
This is to certify that the project report entitled ‘Image to cartoon converter.
Is a bonafied report of the work carried by Ayushi Bhardwaj under guidance and
supervision for the partial fulfilment of degree of the B.tech CSE at Suresh Gyan
To the best of our knowledge and belief, this work embodies the work of candidates
themselves, has duly been completed, fulfils the requirement of the ordinance
relating to the bachelor degree of the university and is up to the standard in respect
4|Page
Table of Contents
Title Page
1. INTRODUCTION 8
2: LITERATURE REVIEW 9
2.1 Literature Survey
2.2 Modules
3: PROBLEM FORMULATION 11
3.1 Description of Problem Domain
5: IMPLEMENTATION 21
5.1 Python
5.2 PY-GAME
5|Page
6: TESTING 27
6.4 OUTPUT
8. LIMITATION 31
9. FUTURESCOPE 31
10. CONCLUSION 32
11. REFERENCES 33
6|Page
1. INTRODUCTION
Playing games is fun and exciting. It gives us relief from stress and unwinds
from our stressful work. Many of us spend our free time or others that use
most of their time in playing and exploring new games. Today, with the raped
development of technology we have, games that are rising up together with it.
Nowadays with technology we have many games that are developed for
computers specifically for windows. With the high technology equipped with
these 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
thenew generation of gadget.
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
movethe 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
(walls,boundaries). As you collect the food, the stake gets longer. The score
also increases. There is no concept of life. Once you hit an obstacle, that's it,
game over.
7|Page
2. LITERATURE REVIEW
The history of the Snake game goes back to the 1970's, the concept originated
inthe 1976 arcade game Blockade, and its simplicity has led to many
implementations. However, it was the 1990'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' 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 cut a 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
casts himself the game is over. The more blocks the snake eats the higher the
score.
8|Page
2.2 MODULES
PyGame
Python has a built-in module that you can use to make random
numbers
import random
9|Page
3. PROBLEM FORMULATION
3.1 DESCRIPTION OF PROBLEM DOMAIN
The core focus of our project was to determine which algorithms would be more
effective in a hard real-time environment. The domainin this case is the Snake
Game, which will, in turn, attempt to identifyan, or even the, algorithm that can
not only play the game but compete with human players. The Snake Game is a
classic arcade style game where it is a single-player game but the focus is to
achievethe highest score possible thus competing with yourself and others.
To play the game one controls a snake by selecting one of the cardinal directions
that the snake will move in. In order to score points you must direct the snake to
an apple, there is only one apple in the game at time. The snake then eats the
apple and increases in length by one square or unit. The game ends when the
snake runs into either the boundaries of the play area or itself, the trailing snake
body. The domain provides a very interesting problem given that the snake always
moves after a given timing delay and the snake continually grows in size. The delay
is the feature that really makes the game difficult because if you do not react fast
enough the snake will continue moving in the last direction given. This causes the
player to try to act as quickly as possible before the snake runs into an obstacle.Also
because the snake is constantly trailed by its tail(being the main obstacle) any move
taken cannot be undone or immediately back tracked. So if you were to make a wrong
turn into a dead end there is no way to reverse that move to back out of the loop.
10 | P a g e
3.2 PROBLEM STATEMENT
The problem is to design a Snake Game which provides the following
functionalities :
1. Snakes can move in a given direction and when they eat thefood,
the length of the snake increases.
1. Snake
2. Cell
3. Board
4. Game
3.3 OBJECTIVE
Snake game is one of the most popular arcade games of all time.
In this game, the main objective of the player is to catch the
maximum number of fruits without hitting the wall or itself.
Creating a snake game can be taken as a challenge while learning
Python or Pygame. It is one of the best beginner – friendly projectsthat
every novice programmer should take as a challenge.
Learning to build a video game is kinda interesting and fun learning.
11 | P a g e
3.4 problem depiction
12 | P a g e
4. SYSTEM DESIGN
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 runninginto 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.
13 | P a g e
4.1 SOFTWARE DESIGN
14 | P a g e
4.2 NON-FUNCTIONAL REQUIREMENTS
I. Robustness:
Robustness is nothing but its ability to tolerate the effects of the system's
fictional body. And it can also be defined by its system’sability that it can
withstand change without transforming its initialstable configuration.
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 247, Availability and Reliability are directly proportional
as reliability increases availability also increases. The sercan have access to
the system all the time
IV. Reusability:
The system can be used any number of times by the specific user. Andthe
reusability is consistent, adaptable and stable
V. Effectiveness:
The algorithm is capable of producing desired results or it has theability to
provide better results.
15 | P a g e
4.4 SOFTWARE REQUIREMENT SPECIFICATION
4.2.1 SRS
Software Requirement Specification (SRS) is the starting point of the software
developing activity. As the 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.
TheSRS is the means of translating the ideas of the minds of clients (the input)
intoa formal document (the output of the requirement phase) The SRS phase
consists of the activities.
16 | P a g e
.4.5 HARDWARE AND SOFTWARE REQUIREMENTS
Software Requirements
Hardware Requirements
17 | P a g e
5. IMPLEMENTATION
5.1 PYTHON
Python's syntax and dynamic typing with its interpreted nature, make it an ideal
language for scripting and rapid application development inmany areas
18 | P a g e
Python Versions
19 | P a g e
5.2 PY-GAME
Python is the most popular programming language or nothing wrongto 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, Matplotih), Artificial intelligence
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, AL, and much
more and it can be amazingly fine. In python, game programming is done in pygame and it is
one of the best modules for doing so
Pygame is a cross-platform set of Python modules which is used to create video games. It
consists of computer graphics and sound libraries designed to be used with the Python
programming language. Pygame was officially written by Pete Shinners to replace PySDL.
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:
20 | P a g e
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 functionsthat have been used in this
Snake Game along with their descriptions.
Function Description
set caption() Will set the caption test on the top of the display
screen.
font SysFont() Will create a Pygame font from the System font
resources
21 | P a g e
.
1. Installing pygame
22 | P a g e
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 tozero and
display I
6. If the snake is over food, eat it, increase the score, grow, move thefood.
8. Go back to step 4
23 | P a g e
6. TESTING
• A good test case is one that has a high probability of finding an asyet
undiscovered
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 of function is put to testing until all the
errors are removed. A successfultest 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 ofthe system.
24 | P a g e
6.2 TEST CASE DESIGN
Unit testing is essentially for the verification of the code produced during the
coding phase and the goal is to test the internal logic of themodule program. In
the Genetic code project, the unit testing is done during the coding phase of data
entry forms whether the functions areworking properly or not. In this phase all
the drivers are tested whether they are rightly connected or not.
25 | P a g e
6.2.5 Validation Testing :
This testing concentrates on confirming that the software is error-freein all
respects. All the specified validations are verified and the software is
subjected to hard core testing. It also aims at determiningthe degree of
deviation that exists in the software designed from the specification, they are
listed out and are corrected
How can we test a full Snake game and, assuming it passes that stage,
3. Is it displaying correctly?
26 | P a g e
5. If we identify an error in the snake, because it's a Class, we will gointo 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 detectedas colliding with something. Does it grow when it
eats cat 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.
7. Using all the screen, it's possible to draw the food or the snake sothat 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?
27 | P a g e
6.4 OUTPUT:
28 | P a g e
Fig : 6.3 IN GAME SCREENSHOTS
29 | P a g e
7. CONTRIBUTION OFTHE PROJECT TO THE SOCIETY
● The classic game is infamous for using your own success against you
when you become so long that you get in your own way. Whilst many
games and activities can teach your child about vital life skills, there
arenot many that would educate on long term strategic planning.
30 | P a g e
8. LIMITATIONS
9. FUTURE SCOPE
In this project, I have used a simple application. This project will be able to
2. We can add more options like Top scores and Player Profile,
31 | P a g e
10. CONCLUSIONS
application with very simple graphics. In this project, youcan play the
popular "Snake Game" just like you played it elsewhere. You have to use
Foods are provided at the several coordinates 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'sgreatest game, but it does
give you an idea of what you can achievewith relatively simple python
programming, and perhaps the basis by which to extend the principles and
32 | P a g e
11. REFERENCES
https://learnopengl.com/In-Practice/2D-Game/Breakout
: https://gigi.nullneuron.net/gigilabs/how-to-make-a-snake-game-in-cpp/
https://www.codewithc.com/snake-game-in-c-console-project/
https://gamedevacademy.org/creating-a-snake-game-in-c-using-sfml/
https://www.youtube.com/watch?v=ApSvqkhz7sA
33 | P a g e