Capstone Model
Capstone Model
Capstone Model
Submitted by
SRIRAM P [192224162]
DIWAKAR S [192210364]
HARISH A [192210189]
SIMATS ENGINEERING
THANDALAM
MARCH 2024
lOMoAR cPSD| 39217614
BONAFIDE CERTIFICATE
Certified that this project report titled “Classic Snake Adventure: Python
Edition” is the Bonafede work of “Sri Ram P [192224162], Diwakar S
[192210364], Harish A [192210189]” who carried out the project work under
my supervision as a batch. Certified further, that to the best of my knowledge the
work reported herein does not form any other project report.
w
lOMoAR cPSD| 39217614
ABSTRACT
The Nokia-inspired Snake game implemented on the 8051-platform utilizing
the AT89551 Microcontroller integrates an 8x8 LED dot matrix display and a
five-way key interface. This classic game experience is enhanced with features
such as a dedicated delay settings key, enabling players to easily adjust the
snake's speed. The game's core functionality relies on the microcontroller's
ability to interpret input from the switches, which are akin to buttons on a
mobile device, for controlling the snake's movements – left, right, up, and
down. Python is employed in the development process to translate the game
logic into code, enabling the display of the snake and fruits on the 8x8 dot-
matrix and facilitating interaction through the switches.
Expanding upon the traditional Snake game, this project seeks to introduce
new elements to elevate the gaming experience. Incorporating computer-
controlled intelligent opponents adds a layer of challenge for players, as they
must navigate the game while contending with dynamically moving
adversaries. Additionally, the multiplayer feature enhances the game's social
aspect, allowing multiple players to engage in competitive gameplay over a
network. By embracing these innovations, the project aims to push the
boundaries of the classic Snake game, transforming it into a more dynamic and
engaging experience.
w
lOMoAR cPSD| 39217614
Table of
Contents
Title Page
CERTIFICATE 1
ABSTRACT 2
TABLE OF CONTENTS 3
LIST OF TABLES 5
LIST OF FIGURES 6
CHAPTER 1: INTRODUCTION 8
2.2 Modules
2.2.1 PyGame
w
lOMoAR cPSD| 39217614
CHAPTER 5: IMPLEMENTATION 16
5.1 Python
5.2 PY-GAME
5.3 Functional Description
5.4 Implementation Steps
5.5 Working Algorithm
REFERENCES 24
w
lOMoAR cPSD| 39217614
List Of
Figures
Title Page
w
lOMoAR cPSD| 39217614
List of Tables
Title Page
w
lOMoAR cPSD| 39217614
Chapter 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.
Snake game is a computer action game, whose goal is to control a stake to moveand
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 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.
w
lOMoAR cPSD| 39217614
2.2 MODULES
2.2.1PyGame
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 has a built-in module that you can use to make randomnumbers
import random
w
lOMoAR cPSD| 39217614
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 cardinaldirections that
the snake will move in. In order to score points you must direct the snake to an apple,
there is only one apple
w
lOMoAR cPSD| 39217614
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.
Fig 3.1.2 : In This Figure, Snake Was Moving Toward AppleBut Got Stuck
Against The Wall Instead
Although with every move your tail moves thus creating a situation where a dead
end or closed loop will no longer be a dead end after xmoves. The apple also can
be very tricky since you cannot know where the next apple position will be and this
makes it difficult to gostraight for the current apple without thinking of how to get
into a good position for the next apple.
w
lOMoAR cPSD| 39217614
1. Snakes can move in a given direction and when they eat thefood, the
length of the snake increases.
2. When the snake crosses itself, the game will be over.
3. Food will be generated at a given interval.
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 themaximum 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.
w
lOMoAR cPSD| 39217614
of the snake and the stake's body follows it around the screen. If thesnake "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.
w
lOMoAR cPSD| 39217614
1. Robustness
2. Reliability
3.Availability
4.Reusability
3. Effectivenes
4.4.1 SRS
The process is order and more nebulous of the two, deals with understanding the
problem, the constraints.
w
lOMoAR cPSD| 39217614
The SRS document is the basic goal of this phase. The purpose of the Software
Requirement Specification is to reduce the communication gap between the clients
and the developers.
The developer is responsible for asking for clarifications, where necessary, andwill
not make alterations without the permission of the client.
The development and deployment of the application requires the followinggeneral and
specific minimum requirements for software:
• Programming Language Translaties-Python 18
The development and deployment of the application requires the followinggeneral and
specific minimum requirements for hardware:
Processor-(32-bit or 64-bit) RAM (8 GB).
w
lOMoAR cPSD| 39217614
CHAPTER 5: IMPLEMENTATION
5.1 PYTHON
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
(Pytorch, TensorFlow), and Game development
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 usethe following command:
pip install pygame
w
lOMoAR cPSD| 39217614
5.3FUNCTION 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.
w
lOMoAR cPSD| 39217614
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.
w
lOMoAR cPSD| 39217614
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 & Displaying the score
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 I
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 thefood.
7. else if the snake is over in a wall, die.
8. Go back to step 4
9. Until the snake die
w
lOMoAR cPSD| 39217614
i. How can we test a full Snake game and, assuming it passes that stage,
ii. how can we playtest that? The functional requirements that we
developed turn, almost immediately.
iii. To display the snake, the first thing we want to do is to make sure thatwe
can draw the snake and move it around on the screen. So our testing for
correct function will be
2. Can I display the snake's head on the screen?
3. Will it move around as I want it to using keyboard control?
4. Is it displaying correctly?
6. 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. One useful test case is to see if everything is being drawn whereyou expect. Because
we aren't.
8. 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?
9. Testing the non-functional requirements often falls into the realmof playability.
a. 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.
w
lOMoAR cPSD| 39217614
w
lOMoAR cPSD| 39217614
CHAPTER 7: CONTRIBUTION
OF THE PROJECT TO THE
SOCIETY
w
lOMoAR cPSD| 39217614
CHAPTER 8 : CONCLUSIONS
The project in python programming of Snake Game is a simple console
application with very simple graphics. In this project, youcan 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 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's greatest 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 create more interesting
games on your own.
LIMITATIONS:
● The existing system only provides a text-based interface, which isnot as user-
friendly as Graphical user Interface.
● The transactions are executed in off-line mode, hence on-line datacapture and
modification is not possible.
FUTURE SCOPE:
In this project, I have used a simple application. This project will be able to be
implemented in future after making some changes and modifications as I made
this project at a low level. Themodifications that can be done in this project are:
w
lOMoAR cPSD| 39217614
REFERENCES
8. "How to Code a Snake Game in Python" by The Renegade Coder (PDF Link:
[therenegadecoder.com/snake_game_python.pdf](therenegadecoder.com/snake_game_pyth
on.pdf))
9. "Creating Snake Game Using Python" by Educational Materials for Python (PDF Link:
[edu-materials.com/snake_game_python.pdf](edu-materials.com/snake_game_python.pdf))
10. "Snake Game Tutorial using Pygame" by Real Python (PDF Link:
[realpython.com/snake_game_pygame.pdf](realpython.com/snake_game_pygame.pdf))
These tutorials cover various aspects of creating a snake game in Python using different
libraries and approaches.