You are on page 1of 11

BMS INSTITUTE OF TECHNOLOGY & MANAGEMENT

YELAHANKA, BENGALURU - 560064

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

UNIX PROGRAMMING

Odd Semester - 2022-23


Report on

“SNAKE GAME”

V Semester
Section A

Submitted By
BHAVANA N S (1BY20CS038)

Under the Guidance of


Mrs. Vishakha Yadav

Assistant Professor

2022-2023
2
Snake Game

INSTITUTE VISION
To emerge as one of the finest technical institutions of higher learning, to develop
engineering professionals who are technically competent, ethical and
environment friendly for betterment of the society.

INSTITUTE MISSION
Accomplish stimulating learning environment through high quality academic
instruction, innovation and industry-institute interface.

DEPARTMENT VISION
To develop technical professionals acquainted with recent trends and
technologies of computer science to serve as valuable resource for the
nation/society.

DEPARTMENT MISSION
Facilitating and exposing the students to various learning opportunities through
dedicated academic teaching, guidance and monitoring.

PROGRAM EDUCATIONAL OBJECTIVES


1. Lead a successful career by designing, analyzing and solving various
problems in the field of Computer Science & Engineering.
2. Pursue higher studies for enduring edification.
3. Exhibit professional and team building attitude along with effective
communication.
4. Identify and provide solutions for sustainable environmental development.

Program Specific Outcomes (PSOs):


1. Analyze the problem and identify computing requirements appropriate to its
solution.
2. Apply design and development principles in the construction of software
systems of varying complexity.

BMSIT&M, DEPARTMENT OF CSE 18CS56


3
Snake Game

UP– 18CS56 - Course Outcomes (COs) w.r.t this PBL


Develop a UNIX Shell/Perl Programming Script using the concepts of UNIX Programming and
CO
Write a report on the Implementation of the same.

Project to Program Outcomes (PO) Mapping

Project Name: <Problem Statement>


COURSE PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
Develop a UNIX √ √ √
Shell/Perl
Programming
Script using the
concepts of
UNIX
Programming
and Write a
report on the
Implementation
of the same.
Program outcomes (POs):
PO1 Engineering knowledge: Apply the knowledge of Mathematics, Science,
Engineering fundamentals and an engineering specialization to the
solution of complex engineering problems
PO2 Problem analysis: Identify, formulate, review research literature, and
analyse complex Engineering problems reaching substantiated conclusions
using first principles of mathematics, Natural sciences and engineering
sciences
PO3 Design/development of solutions: Design solutions for complex
engineering problems and design system components or processes that
meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental
considerations.
PO4 Conduct investigations of complex problems: Use research-based
knowledge and research methods including design of experiments, analysis
and interpretation of data, and synthesis of the Information to provide valid
conclusions
PO5 Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern Engineering and IT tools including prediction and
modelling to complex engineering activities with an understanding of the
limitations.
PO6 The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and
the consequent responsibilities relevant to the professional engineering
practice.
PO7 Environment and sustainability: Understand the impact of the
professional engineering solutions in societal and environmental contexts,
and demonstrate the knowledge of, and need for Sustainable development
PO8 Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.

BMSIT&M, DEPARTMENT OF CSE 18CS56


4
Snake Game

PO9 Individual and team work: Function effectively as an individual, and as a


member or leader in diverse teams, and in multidisciplinary settings
PO10 Communication: Communicate effectively on complex engineering
activities with the engineering Community and with society at large, such
as, being able to comprehend and write effective reports And design
documentation, make effective presentations, and give and receive clear
instructions.
PO11 Project management and finance: Demonstrate knowledge and
understanding of the Engineering and management principles and apply
these to one’s own work, as a member and Leader in a team, to manage
projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life-long learning in the broadest
context of technological change.

Project Name: Problem Statement

COURSE PSO1 PSO2


Develop a UNIX Y Y
Shell/Perl
Programming
Script using the
concepts of
UNIX
Programming
and Write a
report on the
Implementation
of the same.

Project to Program Specific Outcomes (PSO) Mapping

Program Specific Outcomes (PSOs):


PSO1 Analyze the problem and identify computing requirements appropriate to its
solution.
PSO2 Apply design and development principles in the construction of software systems
of varying complexity.

BMSIT&M, DEPARTMENT OF CSE 18CS56


5
Snake Game

ABSTRACT:

This project aims to bring the fun and simplicity of snake game with some new features.
This basic Snake Game provides the following functionalities:
 Snake can move in a given direction and when it eats the food, the length of snake
increases.
 When the snake crosses itself, the game will be over.

This project explores a new dimension in the traditional snake game to make
it more interesting and challenging.

INTRODUCTION:

The program generates a snake game in your Unix machine terminal window. The goal
is to have the snake eat the food, placed randomly on the screen. The more food the snake
eats, the longer it gets and the faster it crawls, making the game more difficult. The snake
can traverse anywhere, in direction (up, down, left, right) provided it doesn't crawl into itself.

Perl Programming:

Perl is an interpreted language, which means you will always need the Perl interpreter
which will compile and execute your program each time you run it. Instead of compiling your
program into bytecode, like in C++ or Pascal, and then executing it, you can simply copy
your program's source code to a different computer (that has the Perl interpreter) and run it.

Perl is a script language, which is compiled each time before running. That unix knows
that it is a perl script there must be the following header at the topline of every perl
script: #!/usr/bin/perl where the path to perl has to be correct and the line must not exeed
32 charachters.

Perl Features

 Perl takes the best features from other languages, such as C, awk, sed, sh, and
BASIC, among others.
 Perls database integration interface DBI supports third-party databases
including Oracle, Sybase, Postgres, MySQL and others.
 Perl works with HTML, XML, and other mark-up languages.
 Perl supports Unicode.
 Perl is Y2K compliant.
 Perl supports both procedural and object-oriented programming.
 Perl interfaces with external C/C++ libraries through XS or SWIG.
 Perl is extensible. There are over 20,000 third party modules available from the
Comprehensive Perl Archive Network (CPAN).

BMSIT&M, DEPARTMENT OF CSE 18CS56


6
Snake Game

IMPLEMENTATION SNAPSHOTS:

First, we need a 2D grid and some constants to label the blocks, which are described bellow:

1. HEAD
o follows input or block directions
o creates BODY blocks
2. BODY
o represents the body of the snake
3. TAIL
o follows block directions
o changes TAIL to VOID
o changes BODY to TAIL
4. FOOD
o suspends TAIL actions
5. VOID
o represents an empty block

Initially, the grid is created with all the blocks labeled as VOID

After we have the 2D grid, we need to create the snake itself and the food source. Currently,
the snake has no BODY, only the HEAD and the TAIL, both with a left (⬅) direction
specified:

After applying the HEAD definition, the HEAD moves to the left by one block and creates a
new BODY block in its old position:

BMSIT&M, DEPARTMENT OF CSE 18CS56


7
Snake Game

Following the TAIL definition, the TAIL moves to the left by one block and replaces
the BODY label with TAIL and the old TAIL with VOID:

If we now press the up-arrow key (⬆), the HEAD will move upwards, instead of following the
block direction. Also, because the HEAD encountered FOOD this time, the TAIL step is
skipped, so the snake grows by one BODY block without it being removed by the TAIL.
The new BODY block always stores the current HEAD direction:

In the next step, the HEAD follows its block direction and continues to move upwards,
creating a new BODY block in its old place:

BMSIT&M, DEPARTMENT OF CSE 18CS56


8
Snake Game

Because no FOOD was encountered this time, the TAIL will follow its block direction and
replace BODY with TAIL, but it will never change the block direction:

BMSIT&M, DEPARTMENT OF CSE 18CS56


9
Snake Game

BMSIT&M, DEPARTMENT OF CSE 18CS56


10
Snake Game

OUTPUT SNAPSHOTS:

REFERENCES:
1. Learning Perl – 5th Edition O’Reilly Publications Randal L. Schwartz Tom Phoenix and
Brian D. Foy
2. Perl Programming- Programming Language by Tutorial’s point Simply Easy
Learning Publications
3. L. Wall, T. Christiansen and R.L. Schwartz, Programming Perl, Sebastapol,
Calif.,, 1997.
4. S. Srinivasan, Advanced Perl Programming, Sebastapol, Calif.,, 1996.
5. Geeks-for-geeks: https://www.geeksforgeeks.org/perl-programming-language/
6. Why Perl is still relevant in 2022?: https://stackoverflow.blog/2022/07/06/why-perl-is-still-
relevant-in-2022/

BMSIT&M, DEPARTMENT OF CSE 18CS56


11
Snake Game

BMSIT&M, DEPARTMENT OF CSE 18CS56

You might also like