Professional Documents
Culture Documents
ENGINEERING AND
TECHNOLOGY, DURGAPUR
A
Design lab Project Report
on
“TIC TAC TOE GAME IN JAVA”
Submitted in the Partial Fulfilment of the Requirement for the
Award of the Degree of
BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND ENGINEERING
Submitted by
SAJAN SUMAN , SNEH NAYAN, ANIMESH PRASAD
College roll no. :- 162095459, 162109525,162126648
University roll no. :-12500116031, 12500116017,12500116113
Subject : Design lab(CS891)
3.3 Platform
Windows xp/7/8/10
Next, decide which player will be X’s and which will be O’s.
The player who is using X’s goes first. That player marks an X in any of the nine sections of
the grid.
Now the other player marks an O in any unused section of the grid.
Alternate turns until one player has all three of their symbols in any row or diagonal, or until
all spaces of the grid have been used. In the diagram below, X wins.
If neither player was able to get three symbols in a row or diagonal, the game is a draw and
Nobody wins.
New/End
If it’s a Tie ……..Game…..
(b) Win condition when all fields in the same column belong to same player
(c) win condition when all fields are in the diagonal belong to same player
Game Draw condition when all fields have a value other than empty, but no win conditions
apply.
Whenever the status in any field changes, the check method is invoked in the board class. If
any win condition is applicable board sets the ‘Game End’ as true and display the result of
game. In this the program disables the ‘XO’ buttons and highlights the winning row, column
or diagonal with the play symbol of the winning player.
7. STRATEGY
Optimal strategy for player ‘X’. In each grid, the shaded ‘X’ denotes the optimal move and
the location of O’s next moves gives the next sub-grid to examine. Note that only two
sequences of moves by O (both starting with centre, top-right, left-mid) lead to a draw, with
the remaining sequences leading to wins from ‘X’.
A player can play perfect tic-tac-toe(win or draw) given they choose the first possible move
from the following list :
(a) Win : If the player has two in a row, he or she can place a third to get three in a row.
(b) Block : If the opponent has two in a row, the player must play the third himself or herself
to block them.
(c) Fork : Creation of an opportunity where the player has two threads to win (two non-
blocked lines of a).
(d) Blocking an Opponent’s Stroke :
• Option 1 : The player should create two in a row to force the opponent into defining
as long as it doesn’t result in them creating a fork.
For example : if ‘X’ has a corner, ‘O’ has the centre, and ‘X’ has the opposite
corner as well ‘O’ must not play a corner in order to win (playing a corner in this
scenario creates a fork for ‘X’ to win).
• Option 2 : If there is a configuration where the opponent can fork ,the player should
block the fork.
(e) Centre : A player marks the centre (if it the first move of the player, playing on a corner
gives ‘O’ more opportunities to make a mistake and may therefore be the better choice,
however, it makes no difference between perfect players).
(f) Opposite Corner : If the opponent is in the corner, the player plays the opposite corner.
9. PROJECT SCREEN SHOTS
10. CONCLUSION
In the end we would like to conclude that my aim to make this project was to research in the
field of game development in java and implementation of artificial intelligence by developing
logic for game. Some scope of improvement are also there in the project which will be
rectified in future advancements of the project. We came to know from this project that
playing from a perfect algorithm is very difficult.
The paper presents an algorithm to predict the win cases or draw cases of the tic-tac-toe game
The algorithm is implemented in java using min max algorithm. The concept of graph theory
or combinational game theory is utilized to implement this game. This algorithm calculates
only one step ahead using min-max algorithm In an ideal scenario, a player must calculate all
the possibilities to ensure the success Tic-tac-toe is a small game hence an unbeatable
algorithm can be developed because the state space tree generated will be small. The coding
structure we used in our experiments includes eight expert networks, each with three inputs
and nine outputs, and one gate network, which has nine inputs and eight output. In our
experiment, no a priori information regarding the object to the game was offered to the
evolutionary algorithm. No hints regarding appropriate moves were given, nor were there any
attempts to assign values to various board patterns. The only given information was that the
three inputs of each expert network are in a row, a column, or a diagonal in the board. The
final outcome (win, lose, draw) was the only information available regarding the quality of
the play. From the result of those experiments, the influence of the payoff function on the
performance of evolving neural network is obvious. What we can do in the future is to add
hidden layers both in the gate network and expert networks in order to optimize the
performance (win more, lose less) of the network. And we can use non-linearity function in
expert and gate networks.
11. REFERENCES
[1] Head First Java by Katty Sierra.
[2] Herbet Schildt, The complete reference : Sixth edition.
[3] Youtube/Arend Peter Teaches.
[4] Website : Github.com