You are on page 1of 24

A PROJECT REPORT

ON
TIC-TAC-TOE GAME
Submitted By :
KRISHNA SHREE TRIPATHI – 220101120134
BURAGAPU MOUNIKA– 22010120139
BURAGAPU HARIKA– 220101120141
ROKKAM DIVYA- 220101120150

In partial fulfillment of the requirement for award of the degree


of
BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE & ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


SCHOOL OF ENGINEERING &TECHNOLOGY,
CENTURION UNIVERSITY OF TECHNOLOGY AND MANAGEMENT,
R.SITAPUR, PARALAKHEMUNDI-761211

Page 1 of 24
CERTIFICATE

This is to be certified that the project entitled “ TIC – TAC – TOE GAME ” has been
submitted for the Bachelor of Technology in Computer Science Engineering of School of
Engineering & Technology, CUTM, Paralakhemundhi during the academic year 2022-2023
is a persuasive piece of project work carried out by, “KRISHNASHREE TRIPATHI”
towards the partial fulfillment for award of the degree (B.Tech.) under the guidance of “Prof.
Tofan Kumar Nahak” and no part there of has been submitted by them for any degree to the
best of my knowledge.

Signature of HOD Signature of Project Guide


Mr. Debendra Maharana Prof. Tofan Kumar Nahak

Page 2 of 24
CERTIFICATE

This is to be certified that the project entitled “TIC – TAC – TOE GAME” has been
submitted for the Bachelor of Technology in Computer Science Engineering of School of
Engineering & Technology, CUTM, Paralakhemundi during the academic year 2022-2023 is
a persuasive piece of project work carried out by, “BURAGAPU MOUNIKA” towards the
partial fulfillment for award of the degree (B.Tech.) under the guidance of “Prof. Tofan
Kumar Nahak” and no part there of has been submitted by them for any degree to the best
of my knowledge.

Signature of HOD Signature of Project Guide


Mr. Debendra Maharana Prof. Tofan Kumar Nahak

Page 3 of 24
CERTIFICATE

This is to be certified that the project entitled “TIC – TAC – TOE GAME” has been
submitted for the Bachelor of Technology in Computer Science Engineering of School of
Engineering & Technology, CUTM, Paralakhemundi during the academic year 2022-2023 is
a persuasive piece of project work carried out by, “BURAGAPU HARIKA” towards the
partial fulfillment for award of the degree (B.Tech.) under the guidance of “Prof. Tofan
Kumar Nahak” and no part there of has been submitted by them for any degree to the best
of my knowledge.

Signature of HOD Signature of Project Guide


Mr. Debendra Maharana Prof. Tofan Kumar Naha

Page 4 of 24
CERTIFICATE

This is to be certified that the project entitled “TIC – TAC – TOE GAME” has been
submitted for the Bachelor of Technology in Computer Science Engineering of School of
Engineering & Technology, CUTM, Paralakhemundi during the academic year 2022-2023 is
a persuasive piece of project work carried out by, “ROKKAM DIVYA” towards the partial
fulfillment for award of the degree (B.Tech.) under the guidance of “Prof. Tofan Kumar
Nahak” and no part there of has been submitted by them for any degree to the best of my
knowledge.

Signature of HOD Signature of Project Guide


Mr. Debendra Maharana Prof. Tofan Kumar Nahak

Page 5 of 24
Objectives:
Our project name is Tic-Tac-Toe game. This game is very popular and is fairly simple by itself. It is
actually a two player game. In this game, there isa board with
nxn squares. In our game, it is 3 x 3 squares. The goal of Tic-Tac-Toe is to be one of the
players to get three same symbols in a row - horizontally, vertically or diagonally - on a 3 x 3 grid.
2. Overview:
This game can be played in a 3x3 grid (shown in the figure 2.1) .The game can be played by two
players. There are two options for players:(a) Human (b) Computer
Figure: 2.1

2.1 Players:
For the option human, both the players are human and for the option computer, the first player is human and
the second player is computer.

2.2 Theory of Game:

A player can choose between two symbols with his opponent, usual games use “X” and “O”.
If first player choose “X” then the second player have to play with “O” and vice versa. A
player marks any of the 3x3 squares with his symbol (may be “X” or “O”)and his aim is to create
a straight line horizontally or vertically or diagonally with two intensions: a) Create a straight line
before his opponent to win the game. b) Restrict his opponent from creating a straight line
first. In case logically no one can create a straight line with his own symbol, the game results
a tie. Hence there are only three possible results – a player wins, his opponent(human or
computer) wins or it’s a tie.

Page 6 of 24
If any player is able to draw three Xs or three Os in the following combinations then that
player wins. The combinations are: a) 1, 2, 3 b) 4, 5, 6 c) 7, 8, 9 d) 1, 4, 7e)
2, 5,8 f) 3, 6, 9 h) 1, 5, 9 i) 3, 5, 7

3. Core Logic - AI:


There are two core logics in this game – when both players are human, andwhen one is
computer. Suppose the player use X and the computer use O .The logic used for the AI is as
follows:
3.1 First move:
a) If the center is free, get the center . (Figure: 3.1) b) Otherwise, get any of the corners.
(Figure: 3.2)
X
3.2 Second move:
a) Block user from winning. (Figure: 3.3) b) Option for winning by applying the following
logic:If the center is occupied by user, get any of the corners.(Figure: 3.4)
Figure: 3.3 Figure: 3.4
XX XOOXX
Figure: 3.2Figure: 3.1
O

Page 7 of 24
O

Page 8 of 24
Page 9 of 24
Page 10 of 24
Page 11 of 24
Otherwise, the following cases happen:
Case 1:
XOX
Figure: 3.5

If any situation arises like the figure 3.5 then the computer sets its symbolany one of the position
among 2, 4, 6 and 8.
Case 2:
X4 O 6X
Figure: 3.6 Figure: 3.7 Figure: 3.8
If any situation arises like the figure 3.6 or figure 3.7 or figure 3.8 then thecomputer sets its
symbol at any position among 4 and 6.
X4 O 6XX4O6XO

Page 12 of 24
Page 13 of 24
Page 14 of 24
Case 3:
2O XX 8
Figure: 3.9 Figure: 3.10 Figure: 3.11

If any situation arises like the figure 3.9 or figure 3.10 or figure 3.11 then thecomputer sets its
symbol at any position among 2 and 8.
Case 4:
Figure: 3.12 Figure: 3.13Figure: 3.14 Figure: 3.15
If any situation arises like the figure 3.12 or figure 3.13 or figure 3.14 or3.15 then the
computer sets its symbol at any position among 1, 3, 7 and 9.
2X O X82X O8 X1 X 3X O7 91 X 3O X7 91 3X O7 X 91 3O X7 X 9

Page 15 of 24
Page 16 of 24
Page 17 of 24
3.3 Third and fourth move:
a) Option for winning. (Figure: 3.16) b) Block user from winning. (Figure: 3.17)c) Randomly
play a move. (Figure: 3.18)
O XX OX
Figure: 3.16 Figure: 3.17Figure: 3.18
4. Core Logic - Humans:
For each move, check whether any 3 combination is occupied by any playerand display the
winner accordingly.
5. Classes:
There are two classes in our program .One class is Main.java and another is NewGame.java.
OX OX XX X OO O XXO

Page 18 of 24
Page 19 of 24
Page 20 of 24
5.1 Class Main:
In this class the main task of the game is done.
Figure: 5.1
5.2 Class NewGame:
This class is used to show the dialog for choosing options.
Figure: 5.2

Page 21 of 24
Page 22 of 24
6. Methods:
The methods we used in our program are as follows:
private void strongLevel ():
To apply artificial intelligence in our program.
private int checkRow (int rownum, String rowname):
To check the combination whether any two symbols(X orO) are same for winning or
blocking .
private int check Column(int column num, String column name):
To check the combination whether any two symbols(X orO) are same for winning or
blocking .
private Boolean check Corner(String corner name, int count1):
To check the combination whether any two symbols(X or O)are same for winning or
blocking.
private void start New Game():
To display the options for player.
private void set Value(int number, int position):
To set the symbols in the right place for winning and blocking .
private void set Else():
To set the symbols in an empty place randomly.
private void set Corner():
To create scope for computer to win in the third move.

7. Limitations:
1. GUI is not so attractive.2. Only mouse interface is implemented, keyboard is not activated in the
game.
8.

Future plan
:
1. Keyboard functions will be added.2. We want to design more complex boards for the game
in future.
Reference:
Books:
H.M.Deitel and P.J.Deital, Java How to program: Sixth Edition Herbert Schildt, The
Complete Reference: Fifth edition

Page 23 of 24
THANK YOU

Page 24 of 24

You might also like