Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

DEPARTMENT OF INFORMATION SCIENCE AND

ENGINEERING

“THE GAME OF TILES”


DAA-UNIX EL COMPONENT

Under the guidance of

Swetha S and Bk Srinivas

Assistant professors

Dept. of ISE
RV College of Engineering
Name USN
Aditya Gehlawat 1RV20IS016

Pankaj 1RV20IS052

GROUP MEMBERS:

ACKNOWLEDGEMENT
The completion of this report could not have been possible without
the assistance and guidance of our professors, BK Srinivas and
Swetha S. We cannot express enough thanks for his continued support
and supervision throughout this undertaking.

We would also like to express our deep sense of gratitude towards our
HOD, Dr B.M Sagar, and Principal, Dr K N Subramanya for giving
us this opportunity and for their guidance in the completion of our
report. Lastly, we would also like to thank all the faculty members for
their constant encouragement and cooperation.
Serial number TITLE PAGE no:

1 ABSTRACT 4

2 INTRODUCTION 4

3 METHODOLOGY 5

4 IMPLEMENTATION 6

5 OUTPUT 9

6 CONCLUSION 10

TABLE OF CONTENTS

1. 1 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.

2. 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.

2.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.

2.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.


3. Methodology and Framework

3.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

3.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.

4. Implementation

4.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

4.2 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.

5. Design and analysis component

A*algorithm:
To approximate the shortest path in real-life situations, like- in maps,
games where there can be many hindrances. * algorithm is a searching
algorithm that searches for the shortest path between the initial and
the final state. It is used in various applications, such as maps. In
maps the A* algorithm is used to calculate the shortest distance
between the source (initial state) and the destination (final state).

Node and graph:


Each configuration of this game corresponds to a node in its state
graph as shown below. So in order to solve this game, we need to find
a path that links node start to node target via a sequence of
intermediate nodes.

5. Snapshots
6. 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.

7. 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.

8. References

1. https://docs.cs50.net/problems/fifteen/fifteen.html

2. https://dev.to/jemaloqiu/a-algorithm-for-solving-sliding-tiles-

game

9. Readme File

https://raw.githubusercontent.com/Dhisha2022/Aditya202/main/

README.md

You might also like