You are on page 1of 4

Tic-Tac-Toe Game with a New Aspect

Shaila Parekh#, Shashank Prabhu#


#
Mukesh Patel School of Technology Management & Engineering,
SVKM’s NMIMS University
1
shaila.parekh@rediffmail.com
2
shashankprabhu.sp@rediffmail.com

Abstract— This study exhibits the application of the concept of his/her move in order to not lose the game. Every player
matrices, probability and optimization in making an electronic makes strategies and looks for the most effective move which
Tic-Tac-Toe game using logic gates and exhibiting the concept of would best block the opponent’s chances of winning, as in [5].
Boolean algebra. For a finite number of moves in every single Reference [3] shows, the weighted superposition of all such
game of Tic-Tac-Toe, the moves are recorded in a 3x3 matrix
moves gives the significant blocking move. People have
and the subsequent solution, or a winning combination, is
presented from the data obtained by playing the electronic game. different strategies and different ways of winning a game.
The solution is also displayed electronically using an LED. The Genetic algorithms can be used in evolving a number of no-
circuit has been designed in a way to apply Boolean logic to loss strategies, as in [6]. This paper focusses on giving a
analyze player’s moves and thus, give a corresponding output mathematical support to the importance and effectiveness of
from the electronic game and use it in matrices. The electronic the blocking move that the player ‘O’ can use to block player
Tic-Tac-Toe game is played randomly between 20 pairs of ‘X’ from winning.
players. The impact of different opening moves is observed. Also,
effect of different strategies, aggressive or defensive, on the II. THEORY BEHIND LOGIC GATES
outcome of the game is explored. The concept of Boolean algebra,
logic gates, matrices and probability is applied in this game to A. Electronics (digital logic):
make the foundation of the logic for this game. The most Digital logics consists of different domains, we tried to
productive position for placing an ‘X’ or ‘O’ is found out using
explore the domain of Boolean algebra and Logic Gates.
probabilities. Also the most effective blocking move is found out
through which a player placing ‘O’ can block ‘X’ from winning. There are various rules for Boolean algebra while doing the
The skills help in understanding what strategy can be simplification of a logic circuit equation. There are seven
implemented to be on the winning side. The study is developed types of Logic Gates available. One can use any according to
with an attempt to realistically model a tic-tac-toe game, and circuit to be designed and implemented. We made the circuit
help in reflecting major tendencies. This knowledge helps in for playing Tic-Tac-Toe using the OR gate. OR Gate: Boolean
understanding what strategy to implement to be on the winning Equation: Z = X+Y. The Tic-Tac-Toe circuit is made using
side. five OR gates and eighteen LED’s to obtain an optimized
circuit. OR gate was the choice amongst the logic gates so that
Keywords— Tic-Tac-Toe game, probability, blocking move in a it is easy for the player to play and the circuit could be made
Tic-Tac-Toe game, electronic game, digital logic. less complicated.
I. INTRODUCTION B. Components:
Boolean algebra is concerned with logic gates; it is a Breadboard, LED’s (Green and Yellow), Wires, Power
collection of relevant logics operated together, as in [1]. The Supply, Logic gate: OR gate (IC 7432)
game “Tic-Tac-Toe” is one game which uses the concept of
logic gates and probability. The basic idea in developing this C. Winning Situation:
game is by combining the mathematical concept with Player X or O wins if any of them succeed to glow three
electronics knowledge. The main concern of people is to consecutive LED’s vertically or horizontally or diagonally. If
simplify the equation that can be understood by every user. A three LED’s of same color glow in any of the previously
long and complex logic equation can be simplified using the mentioned direction, that particular player wins the game.
various laws and rules of Boolean algebra to make it simple Both players should try to obstruct each other’s move but the
and efficient, as in [2]. A basic Tic-Tac-Toe game is known smarter one can definitely win the game and see the output
by all, but we tried to give it a different view by combining it through the glowing LED’s.
with the field of electronics and by using LED’s. The
computations exhibited later on in the paper successfully find
out the probability of the effective blocking moves and that of III. METHODOLOGY
the winning move which effectively puts the player in the The output of 20 games played through the electronic Tic-
wining position. The probabilities of the positions in both the Tac-Toe circuit is noted down in a 3*3 matrix where X is
blocking scenario as well as the winning scenario helps to represented using 1 and O using 0. An average is taken of the
understand the positions where one can profitably place 20 matrices and 1 single matrix is built on which different

978-1-4799-6896-1/14/$31.00 ©2014 IEEE


computations are done to get various inferences. Basically, the 2,1 2 0.285714
circuit is used for the inputs of the matrix. The standard way is 2,2 0 0
to take any random input in the matrix but we took the inputs
of the matrix through the electronic way. 2,3 0 0
Out of the 20 sample games played, the following were the 3,1 2 0.153846
outcomes: 3,2 0 0
Count of Blanks in a position (i, j) for i=1,2,3 and
j=1,2,3 :- 3,3 3 0.214286
1 5 1
1 0 4 The following are the total probabilities of placing an X in
a particular position and winning the game ultimately.
2 4 0
TABLE III
Count of ‘X’s in a position (i, j) for i=1,2,3 and j=1,2,3 :- PROBABILITY OF WINNING, GIVEN THE POSITION OF PLACING X
15 7 9
Position Probability
7 8 11
1,1 0.466667
13 6 14
1,2 0.428571
Count of ‘O’s in a position (i, j) for i=1,2,3 and j=1,2,3 :-
4 8 10 1,3 0.444444
12 12 5 2,1 0.714286
5 10 6 2,2 0.5
2,3 0.272727
After this, the number of ‘X’ in a particular position was 3,1 0.461538
calculated in a winning cause. The following are the
3,2 0
probabilities of placing an X in a particular position and
getting the position included in a winning trio. 3,3 0.642857
TABLE I
PROBABILITY OF WINNING WITH INCLUSION IN WINNING TRIO, GIVEN THE Now, following are the total probabilities of placing an X in
POSITION OF PLACING X
a particular position and ending the game in a draw.
Position Number Probability TABLE IV
1,1 6 0.4 PROBABILITY OF DRAWING THE GAME, GIVEN THE POSITION OF PLACING X

1,2 0 0 Position Number Probability


1,3 4 0.44444 1,1 8 0.533333
2,1 3 0.42857 1,2 4 0.571429
2,2 4 0.5 1,3 5 0.555556
2,3 3 0.27272 2,1 2 0.285714
3,1 4 0.30769 2,2 4 0.5
3,2 0 0 2,3 8 0.727273
3,3 6 0.42857 3,1 7 0.538462
3,2 6 1
The following are the probabilities of placing an X in a 3,3 5 0.357143
particular position and winning the game ultimately, but
without getting the position included in the winning trio.
In the sample 20 games of Tic-Tac-Toe that were played,
TABLE III there were no games in which the player placing ‘O’s won the
PROBABILITY OF WINNING WITHOUT INCLUSION IN WINNING TRIO, GIVEN
THE POSITION OF PLACING X game. The following are the probabilities of placing an O in a
particular position in a losing cause.
Position Number Probability
TABLE V
1,1 1 0.066667 PROBABILITY OF LOSING THE GAME, GIVEN THE POSITION OF PLACING O
1,2 3 0.428571 Position Number Probability
1,3 0 0 1,1 2 0.5
1,2 2 0.25 position in an opposite way to each other. If probability of X
1,3 5 0.5 increases, that of O decreases.
Plotting a graph for the probabilities in table 3 and table 6,
2,1 4 0.333333 the following can be observed:
2,2 6 0.5 0.9
2,3 3 0.6 0.8 Win-Block Scenario
3,1 2 0.4 0.7
3,2 6 0.6 0.6
0.5
3,3 1 0.166667

Probability
X
0.4
0.3 O
The following are the probabilities of placing an O in a
particular position and ending the game in a draw. 0.2
TABLE VI 0.1
PROBABILITY OF DRAWING THE GAME, GIVEN THE POSITION OF PLACING O 0
Position Number Probability 11 12 13 21 22 23 31 32 33
Position
1,1 2 0.5
1,2 6 0.75 Fig. 2 Win-Block Scenario graphical scenario

1,3 5 0.5 The above graph shows that in a win-block scenario, i.e.,
2,1 8 0.666667 when X focusses on winning possibilities and O focusses on
blocking X, the probabilities vary for almost each position in a
2,2 6 0.5 direct way to each other. If probability of X increases, that of
2,3 2 0.4 O decreases.
3,1 3 0.6 V. CONCLUSIONS
3,2 4 0.4 This paper, imitated the virtual life Tic-Tac-Toe game in
3,3 5 0.833333 the form of electronic Tic-Tac-Toe. The concepts of matrices
and digital logic make the foundation for this game and thus
the circuit is developed. The concept of logic gate to extract
IV. DISCUSSION the input for the matrix is used. Different computations are
done and outputs such as the most probable direction of
It can clearly be observed from the probabilities that by winning, the optimized solution, the most productive place in
placing an X at the position (2, 1) the player has the highest the matrix, the most probable place of a win, etc. are
chance of winning the game. Also the player placing an O has generated from the matrix, thus giving inputs from the
the best chance of blocking the win of X by placing O at electronic Tic-Tac-Toe game. In reference [7] the paper
position (3, 3). Plotting a graph for the probabilities in table 3 “introduces a general algorithm which is useful for finding
and table 5, the following can be observed: both a winning and a blocking move in tic-tac-toe”. In this
0.8 study, we successfully discover and mathematically support
Win-Loss Scenario the effectiveness of the blocking moves and the most probable
0.6
Probability

winning moves.
According to the interests of the designing group the game
0.4 was designed in this way. Some of the elements which can be
X
modified later will include features of creating a better
0.2 interface. New technologies like microcontroller or touch
screens etc. can be used to create more optimized circuits. A
0 single IC can be created that shows the particular player
11 12 13 21 22 23 31 32 33 winning. Sound effects can also be used which will enhance
Position the playing surrounding for the players playing this game.
Reference [4] shows, “a multifunction electronic part is often
Fig. 1 Win-Loss Scenario graphical representation
composed by a great many of basic gates and derived gates.
To analyze such a part is very tedious job. With advent of
The above graph shows that in a win-loss scenario, i.e., knowledge and technique in neural network, the complexity
when X focusses on winning possibilities and O does not can be simplified with this technology to remarkably extent”.
focus on blocking X, the probabilities vary for almost each This technology can be utilized to effectively simplify the
circuit used for Tic-Tac-Toe game.
REFERENCES [4] D. C. T. Tai, and S. Wu, “Logic Gate Analysis with Feed Forward
Neural Network,” WHAMPOA - An Interdisciplinary Journal, pp 235-
[1] E. D. Mares, and K. Tanaka, “Boolean Conservative Extension Results 251, 51(2006).
for some Modal Relevant Logics,” Australasian Journal of Logic, pp [5] G. Hochmuth, “On the Genetic Evolution of a Perfect Tic-Tac-Toe
31-49, Sept. 22, 2010. Strategy”, pages 75-82, Stanford University, Stanford, CA 94305, 2003.
[2] L. Rompis, “Boolean Algebra for Xor-Gates,” Journal of Computer [6] A. Bhatt, P. Varshney, and K. Deb, “Evolution of No-loss Strategies
Sciences and Applications, pp 14-16., 2013 1 (1), DOI: 10.12691/jcsa- for the Game of Tic-Tac-Toe,” IIT, Kanpur, Department of Mechanical
1-1-3. Engineering, KanGAL Report Number 2007002.
[3] J. N. Leaw, and S. A. Cheong, “Strategic insights from playing [7] A. Gordon, “A general algorithm for tic-tac-toe board evaluation,”
quantum tic-tac-toe”, J. Phys. A: Math. Theor. 43 455304., Journal of Computing Sciences in Colleges, vol. 21, pp. 42–46, 2006.
doi:10.1088/1751-8113/43/45/455304, 20 Oct. 2010.

You might also like