You are on page 1of 7

UNIX PROGRAMMING PROJECT

GAME OF TILES

Submitted to: Ms. Archana A

Group Members:

HIMANSHI DWIVEDI,
HARSHIT BHARGAVA,
INDRAJEET SINGH SOLANKI,
HARSH GOEL,
AADHAR KUMAR MISHRA
Declaration

We, Himanshi Dwivedi(1BI19CS065),Indrajeet Singh


Solanki(1BI19CS069),Harshit Bhargava(1BI19CS061),Harsh
Goel(1BI19CS059),Aadhar Kumar Mishra(1BI19CS003),students of 5th
semester (Computer Science Engineering), Bangalore Institute Of
Technology, hereby declare that the project work entitled “Game of Tiles”
submitted to Ms. Archana A during the academic year 2021-22, is a record
of an original work done by us. This project is submitted in the fulfilment
of the requirement by the course(18CS56) – Unix Programming

Date: 29.01.2022
Place: BENGALURU
o Harshit
Bhargava(1BI19CS061)
o Himanshi
Dwivedi(1BI19CS065)
o Indrajeet Singh
Solanki(1BI19CS069)
o Harsh Goel(1BI19CS059)
o Aadhar Kumar
Mishra(1BI19CS003
Abstract
The Game of Tiles is a puzzle played on a square, two-dimensional board which can be of
dimensions from 3x3 to 9x9 with numbered tiles that slide. The goal of this puzzle is to
arrange the board’s tiles from smallest to largest, left to right, top to bottom, with an empty
space in board’s bottom-right corner. Here we show an example of 4x4 that has numbers
from 1 to 15 and the bottom-right corner is empty.

Figure A.1

Sliding any tile that borders the board’s empty space in that space constitutes a "move."
Although the configuration above depicts a game already won, notice how the tile
numbered 12 or the tile numbered 15 could be slid into the empty space. Tiles may not be
moved diagonally, though, or forcibly removed from the board.
Although other configurations are possible, we shall assume that this game begins with the
board’s tiles in reverse order, from largest to smallest, left to right, top to bottom, with an
empty space in the board’s bottom-right corner. If, however, and only if the board contains
an odd number of tiles (i.e., the height and width of the board are even), the positions of
tiles numbered 1 and 2 must be swapped, as in the below. The puzzle is solvable from this
configuration.

Figure A.2

The puzzle also has an autocomplete feature available for 3x3 and 4x4 grid. The user will be
able to see the sequence in which the puzzle is solved one move at a time from start to the
solution of the puzzle. We also store the minimum number of moves and time of highscore
for each grid size.
Table of contents

1. Introduction
1.1 Challenges 1
1.2. Motivation for the work 1

2. Methodology and Framework


2.1 System Requirement 1
2.2 Algorithms Techniques 1

3. Implementation
3.1 UNIX and its Commands (min 5) 2

3.2 Uses and its Syntax 2

4. Results and Analysis 2

5. Conclusion 3

6. References 3
1

1. Introduction
The Tiles Swap Game is a puzzle played on a square, two-dimensional board with
numbered tiles that slide. The goal of this puzzle is to arrange the board’s tiles from
smallest to largest, left to right, top to bottom, with an empty space in board’s bottom-
right corner.

1.1. Challenges
We started to learn about functions in shell scripting which included the concept of
passing multi-dimensional array to the function as parameters and change this arrays
passed globally. Then we also made database for the game which stores the high
score, which is the lowest number of moves that a user has used to solve the puzzle.
The number of moves and time to complete the game is displayed.

1.2. Motivation for the work


We were interested in game development. We then decided to use Shell Script to
make a game for our project, we found this puzzle game to be interesting and
challenging, and then we explored more about the features that we could possibly add
to this game and the ways in which this can be achieved.

2. Methodology and
Framework

2.1 Requirement
a) Bash shell installed on the system.
b) User must have permission to read, write and make new files.
c) Memory space 4KB

2.2 Algorithms Techniques


a) Accepts arguments from user.
b) Then it creates the required board in the shuffled manner.
c) Then it checks whether the game is won by comparing the required values
with current values of the board.
d) Then it gets the input and calls the move.
e) Basically we are implement all the above functions using fours functions.
2

3. Implementation
3.1 List of UNIX commands
a) Sleep: sleeps current thread
b) Date: gives the date
c) Cat: for file operations
d) Head: gives the first n lines of file
e) Sort: sorts the data
f) Exit, break, clear
g) Local, if, while, array declare, functions
h) Expr: for calculations
i) Printf, echo, read, clear
j) Grep, sed
k) Redirection
l) Command line arguments

3.3 Uses and its syntax


a) init: initialize the board according to user input
b) draw: draws current status of the board
c) Here we use loops and global variable to print it.
d) move: swaps the values according to user value
e) The user enters the tile number so we have to find the index of the number and
check whether it is a valid move. If the move is valid then we swap the
indices.
f) won: checks whether game is completed or not
g) This is done by iterating through each element and comparing with the true
positional value
h) autocomplete: show the user steps to complete the game
i) highscore: gives the high score and updates it
j) We have create a file that stores high score and we retrieve the data and
compare with current high score.

4. Results and Analysis

The user has to move the tiles keeping in mind that the final result should be in
ascending order, and at the end when the ascending order pattern is achieved the game
ends with the number of moves displayed.
3

5. Conclusion

We learned a lot through this project. This project has sharpened our concepts of
UNIX and shell script.

We learned a lot about different documentation. The piece of software we developed


is intended to show the flexibility of UNIX operating system. This project not only
tested our technical skills but also our temperament.

There were many time we almost lost hope but we recovered through constant
concentration and hard work.

If any kind of suggestion, improvements, more efficient development ideas are found,
please feel free to communicate with us.

6. References
[1] Game of fifteen https://docs.cs50.net/problems/fifteen/fifteen.html
[2] Sumitabha Das, Unix Concepts and Applications,

You might also like