You are on page 1of 28

Karnatak Law Society’s

GOGTE INSTITUTE OF TECHNOLOGY


Udyambag, Belagavi -590008
(Autonomous Institution under Visvesvaraya Technological University, Belagavi)
(APPROVED BY AICTE, NEW DELHI)

DEPARTMENT OF MASTER COMPUTER APPLICATIONS

Project Report on
“Android Sudoku Game”
A dissertation report submitted in partial fulfilment of the requirements
for the award of degree of

Master of Computer Applications


Submitted by
Name : Dhanagouda Patil USN : 2GI19MCA65
Name : Darshan Magadum USN : 2GI19MCA63

Under the Guidance of


Mr. Hrishikesh Mogare
Assistant Professor
Department of M.C.A.
K.L.S. Gogte Institute of Technology,
Udyambag Belagavi

Academic Year: 2020 - 21


Karnatak Law Society’s
GOGTE INSTITUTE OF TECHNOLOGY
Udyambag, Belagavi -590008
2020 - 21

Department of Master of Computer Applications


Certificate
This is to certify that Dhanagouda Patil and Darshan Magadum have
completed their project work-1 entitled “Android Sudoku Game” as a partial
fulfilment for the award of the Master of Applications degree, during the
academic year 2020-2021 under my supervision.
Internal Guide
Mr. Hrishikesh Mogare
Assistant Professor
Department of M.C.A.
K.L.S. Gogte Institute of Technology, Belagavi

_______________ ___________________
Head of Department Principal
Dr. S. I. Goudar Dr. J. K. Kittur
Assoc Prof. and Head, Dept of M.C.A. K.L.S. Gogte Institute of
Technology
K.L.S. Gogte Institute of Technology, Belagavi Belagavi
Examine Examiner Examine Examiner Date
r1 1 r2 2
Name Signature Name Signature

ACKNOWLEDGEMENT

Culmination of project is that stage which makes the transformation a mere


theoretical idea into a visible reality. Our project acknowledges guidelines, supervision and a
lot of inspiration. It is time now to acknowledge our obligations to all who have extended
their co-operation all along our study tenure of project work.

We are thankful to Principal Dr. J. K. Kittur for having provided us the academic
environment in contributing to the success of academic project.

We are deeply grateful to Dr. S. I. Goudar our beloved Head of the Department, for
having provided us the academic environment which nurtured our practical skills
contributing to the success of our project.

We are thankful to Mr. Hrishikesh Mogare worthy guide, for his support, cooperation and
presence provided to us during the course of the project. Our diction falls short of words to
gratify the faculty members of our department for being the source of inspiration.

Lastly, with unquantifiable affection and reference We wish to express our sincere
feeling to our parents and friends in the form of words which are restricted in expression and
quantum.

Dhanagouda Patil.
Darshan Magadum.
TABLE OF CONTENTS

1. INTRODUCTION 1
2. LITERATURE SURVEY 2
2.1 EXISTING SYSTEM 2
2.2 PROPOSED SYSTEM 2
3 SYSTEM REQUIREMENTS so on
4 SOFTWARE REQUIREMENTS SPECIFICATIONS
5 SYSTEM DESIGN
5.1 DATA FLOW DIAGRAM
5.2 USE CASE DIAGRAM
5.3 ACTIVITY DIAGRAM
5.4 CLASS DIAGRAM
5.5 E-R DIAGRAM
5.6 DATABASE METADATA
6 IMPLEMENTATION
6.1 MODULE-1
6.2 MODULE-2
6.3 AND SO ON (WRITE YOUR PROJECT MODULE NAMES)
7 TESTING
7.1 UNIT TESTING
7.2 FUNCTIONALITY TESTING
7.3 INTEGRATION TESTING
7.4 VARIFICATION AND VALIDATION TESTING
8 FUTURE ENHANCEMENT
9 CONCLUSION
10 BIBLIOGRAPHY
1. INTRODUCTION

Computers are one of the essential parts of the improvement of information technology.
The computer that was initially only used by academics and the military is now widely used
in various fields, such as business, health, education, psychology, games, and so on. The
development of Android-based adolescent reproductive health promotion is one of the efforts
to increase adolescent knowledge about adolescent reproductive health.

The development of computers began to spread to various fieldsVarious branches of


sciencedeveloped and were born from it, and one of them is artificial intelligence. Artificial
intelligence is a field of computer science that discusses how a computer device can be
programmed with a machine to be able to do what the programmer wants through specific
instructions. The interesting one of this branch of artificial intelligence is where computers
can be made as if they have intelligenc. Contrast-enhanced is the digital manipulating
carried out to increase the contrast and eliminate the noise in digital imaging.

One representation of artificial intelligence science is a Game. With artificial intelligence,


certaingames can be solved through computers. The games that can be classified into
artificial intelligence games are Sudoku. Sudoku is a game that has been popular since the
1970s. This game is like a number game where the player must fill in the available empty
boxes with random numbers 1-9 (standard Sudoku). The rules of the Sudoku game are
straightforward. It is namely filling in a puzzle with random numbers. But it seems like not a
few who fail and cannot finish this game. That's because there are more than thousands of
solutions offered to solve Sudoku puzzles.

Thus came the idea to create an Android application that can generate puzzles and solve
them. Fromthe exposure, it can be determining the limitations of the problem are as follows:

 Making this Sudoku game implements the backtracking algorithm on mobile / Android applications.
 The programming language used is java. Supporting software used to make Sudoku games is Android
studio.
 Sudoku puzzles used are a standard size 9 x 9 boxes.
 The initial element generated consists of a maximum of 36 numbers and a minimum of 27 puzzle
numbers that have been filled in with numbers, and each row, column, and block (3x3) has been
filled in at least one box and may not be empty on each of its genera.
1.1Preface

Sudoku is the Japanese abbreviation of a phrase meaning the digits must remain single,
also known as Number Place, where Su means number, doku which translates as single or
bachelor. Sudoku is not a mathematical or arithmetical puzzle. It works just as well if the
numbers are substituted with letters or some other symbols, but numbers work best. The aim
of the puzzle is to enter a numerical digit from 1 through 9 in each cell of a 9×9 grid made up
of 3×3 subsquares or subgrids, starting with various digits given in some cells; each row,
column, and subsquares region must contain each of the numbers 1 to 9 exactly once.
Throughout this document we refer to the whole puzzle as the grid/game board, a 3x3
subgrid as a block and the individual grids that contains the number as a cell.
1.2Abstraction

Sudoku is a pretty popular number game.The goal of this game is to fill a 9x9 matrix with
unique numbers, and there should not be repeated numbers in each row, column, or block.
This paper proposed a solution to solve Sudoku using the Backtracking Algorithm. This
algorithm is quite efficient because it does not have to check all the possibilities that exist,
but which leads to only the solution that will be processed, namely by pruning every element
that does not lead to the solution. Thus the time required is quite efficient and suitable for use
in reasonably complex numbers games like sudoku. By implementing the backtracking
algorithm in the sudoku game, the complexity of the algorithm can be as large 𝜽 (n3).

A Sudoku starts with some cells containing numbers and the goal is to solve the remaking
this Sudoku game implements the backtracking algorithm on mobile / Android applications.
Proper Sudoku have one solution. The programming language used is java. Supporting
software used to make Sudoku games is Android studio.

Sudoku puzzles used are a standard size 9 x 9 boxes. The initial element generated
consists of a maximum of 36 numbers and a minimum of 27 puzzle numbers that have been
filled in with numbers, and each row, column, and block (3x3) has been filled in at least one
box and may not be empty on each of its genera.maining cells.One or more known Sudoku
which satisfy or nearly satisfy the characteristic being searched for is used as a starting point.
1.3Objective
One common method of searching for Sudoku with a particular characteristic is called neighbor
searching. Using this strategy, one or more known Sudoku which satisfy or nearly satisfy the
characteristic being searched for is used as a starting point, and these Sudoku are then altered to look
for other Sudoku with the property being sought. The alteration can be relocating one or more clue
positions, or removing a small number of clues, and replacing them with a different number of clues.
2. LITERATURE SURVEY

2.1 Existing System

Backtracking Algorithm
D.H. Lehmer was the first to introduce the backtracking algorithm in 1950. The
backtracking algorithm is one of the problem-solving methods included in a strategy based
on searching the solution space, but it does not have to examine all possibilities, only those
that lead to only solutions will be processed. Algorithms backtracking is also an algorithm
that works recursively, where the search process is based on the Depth-First Search (DFS)
algorithm, which is to search for systematic solutions to all possible solutions and search for
answers is done by tracing a tree-shaped structure rooted. Therefore this algorithm is quite
powerful and very good to be applied in problem-solving and to provide artificial intelligence
in the game. Several types of digital games that are generally commonly known by the
public, such as Chess, Math Maze, Tic Tac Toe, to Sudoku can be found a solution by
implementing the backtracking algorithm.

The backtracking algorithm is an improvement of the brute force algorithm, which is to


find solutions to problems among all possible solutions systematically. Backtracking is a
typical form of recursive algorithm and is based on DFS (Depth-First Search) in finding the
right answer. In another sense, the backtracking algorithm works like experimenting with
several possibilities that lead to the solution until it finds the most appropriate one. So there
is no need to check all possible solutions, but it is enough that only leads to the solution,
namely by sorting pruning the nodes that do not lead to the solution. Thus the search time
can be saved. The difference with the brute force algorithm is the basic concept, namely, in
backtracking, all solutions are made in the form of a solution tree (tree), and then the tree will
be traced in DFS (Depth-First Search) to find the best-desired solution.
2.2 Proposed System
The objectives of the proposed Project is to increase the Thinking Capability. The Game
having all the records which u perform in playing you can Select Easy, hard level according
to your choice. You can make your own Sudoku and at any Step you can go back to One
Step as well as you can see the Solution of it. It is manually a very difficult job to perform
and its need a lot of recalling , reminding and mathematical calculation. The game of
“Sudoku” helps to increase mental thinking , vision e.t.c.

2.3 Related Works


 Llyod (2019) Conduct research published by IEEE in international journals entitled “Solving
Sudoku with Ant Colony Optimization.” Says that sudoku game is a famous puzzle game
that is very computationally challenging, so it requires the most powerful and most
sophisticated form of algorithm to solve it.
 Ghosh (2017) International journals published by IEEE did the research entitled “A Simple
Recursive Backtracking Algorithm for Knight’s Tours Puzzle on Standard 8×8 Chessboard”
says the backtracking algorithm is not entirely the best solution in the case of a knight’s tour
game because it executes too long, making it less efficient and practical.
 Schottlender (2014) Conduct research published by IEEE in international journals entitled
“The Effect of Guess Choices on the Efficiency of a Backtracking Algorithm in a Sudoku
Solver.” Using the initial element of a randomly generated sudoku puzzle is better in the
backtracking algorithm compared to using numbers that are already available as starting
elements.
 Szabó (2014) on International journals published by IEEE did the research entitled “Creation
of the Chips Placement Game with Backtracking Method in Borland Pascal” the application
of backtracking algorithm in the creation of the chips placement game is very efficient
because the algorithm can calculate all combinations with a concise code.
 Fermuller (2014) International journals published by IEEE did the research entitled “Semantic Games
with Backtracking for Fuzzy Logics.” implement the backtracking algorithm in Hintikka’s classical
game
4. REQUIREMENT SPECIFICATION
4.1 Project Requirement Specification

Project requirement are conditions or tasks that must be completed to ensure the success or
completion of the project. They provide a clear picture of the work that needs to be done. They’re
meant to align the project’s resources with the objectives of the organization.

4.1.1Software Requirements
 Operating System : windows 7, windows 8, windows 10
 Design : XML
 Tools : Android Emulator Android SDK- adk-bundle-
windows-x86 Jdk-8u66-windows-x86

4.1.2 Hardware Requirements

 Processor : pentinum core i4 and above


 Hard Disk : minimum 500GB
 RAM : minimum 4GB

4.1.3 Languages

 Front end : XML


 Back end : Java
 Scripting Language : Angular JavaScript
5. SYSTEM DESIGN

5.1 Design Decisions


Analysis process is designed to provide an overview of all processes that occur as well as
provide an overview of the parts of the system being designed. In this study, the process
flow shown by a flowchart, which is an algorithm flowchart. The backtracking algorithm
flowchart is a data flow based on an existing algorithm. In this flowchart, the running
algorithm process is explained from the beginning to the end. The backtracking algorithm's
diagram is illustrated in figure 1.

Figure 5.1.1 Algorithms Flowchart


Use Case Diagram

Grid location CChange Enter the

Get Hint

Figure 5.1.2 Use Case Diagram

5.2 Block Diagram Of Sudoku Game

Figure 5.2: Block Diagram


6. IMPLEMENTATION

6.1 Implementation Details


The implementation phase of any project is the most important phase as it yields the final
solution, which solves the problem at hand. The implementation phase involves the actual
materialization of the ideas, which are expressed in the analysis document and developed in
the design phase. Implementation should be perfect mapping of the design document in a
suitable programming language in order to achieve the necessary final product. Often the
product is ruined due to incorrect programming language chosen for implementation or
unsuitable method of programming. It is better for the coding phase to be directly linked to
the design phase in the sense if the design is in terms of object oriented terms then
implementation should be preferably carried out in object oriented way.

6.1 Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/wall"
android:orientation="horizontal"
android:padding="85dip">

<LinearLayout
android:layout_width="249dp"
android:layout_height="250dp"
android:layout_gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/new_button"
android:layout_width="200dp"
android:layout_height="55dp"
android:layout_margin="5dip"
android:background="@drawable/button1"
android:text="@string/new_game_label"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textStyle="bold" />
<Button
android:id="@+id/about_button"
android:layout_width="200dp"
android:layout_height="55dp"
android:layout_margin="5dip"
android:background="@drawable/button1"
android:text="@string/about_label"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textStyle="bold" />

<Button
android:id="@+id/exit_button"
android:layout_width="200dp"
android:layout_height="55dp"
android:layout_margin="5dip"
android:background="@drawable/button1"
android:text="@string/exit_label"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textStyle="bold" />

<CheckBox
android:id="@+id/mus"
style="@android:style/Widget.DeviceDefault.Light.CompoundButton.CheckBox"
android:layout_width="200dp"
android:layout_height="40dp"
android:autoText="false"
android:onClick="onClick"
android:text="Music"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
5.3.2 Keypad.xml

<?xml version="1.0" encoding="utf-8"?>


<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keypad"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<Button android:id="@+id/keypad_1"
android:text="1">
</Button>
<Button android:id="@+id/keypad_2"
android:text="2">
</Button>
<Button android:id="@+id/keypad_3"
android:text="3">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/keypad_4"
android:text="4">
</Button>
<Button android:id="@+id/keypad_5"
android:text="5">
</Button>
<Button android:id="@+id/keypad_6"
android:text="6">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/keypad_7"
android:text="7">
</Button>
<Button android:id="@+id/keypad_8"
android:text="8">
</Button>
<Button android:id="@+id/keypad_9"
android:text="9">
</Button>
</TableRow>
</TableLayout>
6.2 Game.java
package org.ace.game;

import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.style.BackgroundColorSpan;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;

public class Game extends Activity {


private static final String TAG = "Sudoku";

public static final String KEY_DIFFICULTY =


"org.example.sudoku.difficulty";
public static final int DIFFICULTY_EASY = 0;
public static final int DIFFICULTY_MEDIUM = 1;
public static final int DIFFICULTY_HARD = 2;

private int puzzle[] = new int[9 * 9];

private final String easyPuzzle =


"543921876219687543876354219"+
"987465321321798654654132987"+
"765243198432819765198576000";
private final String mediumPuzzle =
"650000070000506000014000005" +
"007009000002314700000700800" +
"500000630000201000030000097";
private final String hardPuzzle =
"009000000080605020501078000" +
"000000700706040102004000000" +
"000720903090301080000000600";

private PuzzleView puzzleView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");

int diff = getIntent().getIntExtra(KEY_DIFFICULTY,


DIFFICULTY_EASY);
puzzle = getPuzzle(diff);
calculateUsedTiles();
puzzleView = new PuzzleView(this);
setContentView(puzzleView);
puzzleView.requestFocus();
}

/** Given a difficulty level, come up with a new puzzle */


private int[] getPuzzle(int diff) {
String puz;
// TODO: Continue last game
switch (diff) {
case DIFFICULTY_HARD:
puz = hardPuzzle;
break;
case DIFFICULTY_MEDIUM:
puz = mediumPuzzle;
break;
case DIFFICULTY_EASY:
default:
puz = easyPuzzle;
break;
}
return fromPuzzleString(puz);
}

/** Convert an array into a puzzle string */


static private String toPuzzleString(int[] puz) {
StringBuilder buf = new StringBuilder();
for (int element : puz) {
buf.append(element);
}
return buf.toString();
}

/** Convert a puzzle string into an array */


static protected int[] fromPuzzleString(String string) {
int[] puz = new int[string.length()];
for (int i = 0; i < puz.length; i++) {
puz[i] = string.charAt(i) - '0';
}
return puz;
}

/** Return the tile at the given coordinates */


private int getTile(int x, int y) {
return puzzle[y * 9 + x];
}

/** Change the tile at the given coordinates */


private void setTile(int x, int y, int value) {
puzzle[y * 9 + x] = value;}
6.3 Sudoku Game.java
package org.ace.game;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;

import java.util.Objects;

public class SudokuGame1 extends Activity implements OnClickListener {

private CheckBox mus;


MediaPlayer mySong;

private static final String TAG = "Sukgludflkgfdkhd";


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Set up click listeners for all the buttons


/* View continueButton = findViewById(R.id.continue_button);
continueButton.setOnClickListener(this);*/
View newButton = findViewById(R.id.new_button);
newButton.setOnClickListener(this);
View aboutButton = findViewById(R.id.about_button);
aboutButton.setOnClickListener(this);
View exitButton = findViewById(R.id.exit_button);
exitButton.setOnClickListener(this);

mus=findViewById(R.id.mus);
mySong = MediaPlayer.create(SudokuGame1.this,R.raw.dash);
mySong.setLooping(true);
}

// ...
public void onClick(View v) {

if(mus.isChecked()){
mySong.start();
}
else {
mySong.pause();
}

switch (v.getId()) {
case R.id.about_button:
Intent i = new Intent(this, About.class);
startActivity(i);
break;
// More buttons go here (if any) ...

case R.id.new_button:
openNewGameDialog();
break;

case R.id.exit_button:
finish();
break;

}
}

protected void onDestroy(){


super.onDestroy();
mySong.stop();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.settings:
startActivity(new Intent(this, Prefs.class));
return true;
// More items go here (if any) ...
}
return false;
}
/** Ask the user what difficulty level they want */
private void openNewGameDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.new_game_title)
.setItems(R.array.difficulty,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface,
int i) {
startGame(i);
}
})
.show();
}

/** Start a new game with the given difficulty level */


private void startGame(int i) {
Log.d(TAG, "clicked on " + i);
Intent intent = new Intent(SudokuGame1.this, Game.class);
intent.putExtra(Game.KEY_DIFFICULTY, i);
startActivity(intent);
}
}
SNAP SHOTS

6.4 User Interface

Figure 6.4.1. User Interface Figure6. 4.2. Levels


6.5 Game View

Figure 6.5.1 User Interface Figure 6.5.2 keypad


7. Testing

7.1 Functional Testing

Functionality QA testers look for the generic problems within the game or its user
interface & graphics, such as game mechanic issues, stability issues, and game
asset integrity. User interface testing ensures user-friendliness of the game

Example: Checking colors and backgrounds, menu structure, screen orientation and


screen resolution, font size, alignment errors, usability, system navigation such as
loading time, timeout and display, messages, sequences, animations and audio
elements aspects of the game, instruction. User Interactions, User Interfaces,
Transactions testing, Calibration and accuracy testing of mobile phone Screen
resolutions, Mobile responsive design testing, Audio quality Testing.

7.2 Compatibility Testing

Checking if the game is compatible across different devices, and on different


configurations of hardware and software.

Example: Install and Uninstall the game on all supported


consoles/desktops/mobiles.

7.3 Performance Testing

The overall performance of the Game is checked. Performance tuning is performed


to optimize game speed.

Importance parameters checked during performance testing

 Battery Consumption: Measure the battery consumption of the mobile game.


Battery Consumption must be optimum over long hours, and game responses
should be satisfactory under varying heavy loads across different devices.
 Processor and memory constraints: Performance counters are used to measure
the CPU and memory consumption of the application.

 Sound Testing: Testing if there is an error in loading the files, listening to sound
files for errors or distortions.
8. Future Enhancement

In Sudoku game better to raise in more complex cases, such as a more complicated
artificial intelligence game so that the algorithm used works more optimally. Likewise, the
layout and appearance of the user interface are more developed. At this writing, the writer
deliberately does not pay attention to the display interface because one of them is wanting to
show more algorithms that work in the system instead of highlighting the game itself. The
other suggestions for the next research are adding another algorithm as a comparison with the
backtracking algorithm in solving the same case or different cases and comparing the running
time and algorithm complexity of the two.

These are some of the main sugestions given by the user for improvement.
 Instant help by giving hints and users progress while playing.
 Score system based on time, accuracy and database to keep track of top ten record.
9. Conclusion

The Sudoku puzzle game application with backtracking algorithm has worked and is
running well.Games will always be the safe for people who want something refreshing to do
during their free time-to unwind and relax. Whether traditional or on the board or on
computer or mobile games there will always be a set of people crazy about games
10. Biblography

[1] M Schottlender 2014 The effect of guess choices on the efficiency of a backtracking
algorithm in a Sudoku solver Long Island Systems, Applications and Technology (LISAT)
Conference armingdale, NY, USA pp. 1–6.

[2] R Szabo 2014 Creation of the chips placement game with backtracking method in
Borland Pascal 11th International Symposium on Electronics and Telecommunications
(ISETC), Timisoara, Romania pp. 1–4.

10.1 References

[1] http://www.sudoku.sourceforge.net/
[2] https://www.sudokuwiki.org/sudoku.htm
[3] http://davidbau.com/archives/2006/09/04/sudoku_generator.html

You might also like