Tic Tac Toe
Tic Tac Toe
Introduction: -
Tic Tac Toe is one of the simplest yet most-challenging games to be invented. Tic- tac -toe, also
known as Think-tac-toe, is a differentiation tool that offers collection of activities from which students can
choose to do to demonstrate their understanding. It's to introduce two features. Bi- coloured LEDs,
microcontrollers and the skill of writing an algorithm. It is actually a two player game. In this game, there
is a board with n x n 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 n x n grid. As this is two player game, both
the payers are human and for the computer option, the first player is human and the second player is
computer. . If the game is played against the "computer" and the computer has a chance of winning, it
appears to have "intelligence."
This is the basis of "Computer Intelligence" or "Artificial Intelligence." The microcontroller we have
chosen is a PIC16F628. The micro is easy to use and has a re-programmable feature that allows it to be
programmed almost any number of times.
The game of Tic Tac Toe is, being simple, easy to play, well known and visual.
Literature review:-
An early variant of Tic-tac-toe was played in Roman Empire, around the first century BC. It was
called Terni Lapilli and instead of having any number of pieces, each player only had three, thus they had
to move them around to empty spaces to keep playing. The different names of the game are more recent.
The first print reference to "noughts and crosses", the British name, appeared in 1864. The first print
reference to a game called "tick-tack-toe" occurred in 1884, but referred to "a children's game played on a
slate, consisting in trying with the eyes shut to bring the pencil down on one of the numbers of a set, the
number hit being scored". "Tic-tac-toe" may also derive from "tick-tack", the name of an old version of
backgammon first described in 1558.
In 1952, Tic-tac-toe became the first known video game, for the EDSAC computer. The computer
player could play perfect games of tic-tac-toe against a human opponent. In 1975, Tic-Tac-Toe was also
used by MIT students to demonstrate the computational power of Tinkertoy elements. The Tinkertoy
computer, made out of (almost) only Tinkertoys, is able to play Tic-Tac-Toe perfectly. It is currently on
display at the Museum of science, Boston.
Circuit Diagram:-
Figure 1.1 Circuit Diagram of Tic Tac Toe
Methodology:-
When the project is turned on, the screen flashes and shows the effectiveness and capability of the
bi-coloured LEDs. This is called the ATTRACT MODE and is sometimes used in amusement machines to
attract players. The LEDs flash from red to orange to green and then a single LED in the centre of the
display gradually changes from red to green. There are 256 steps in the change. To produce this gradual
effect, takes about 20 instructions and the program shows how this is done. Bi-coloured LEDs have 3
leads. The two light-emitting parts of the LED have the cathodes connected together and this is taken to
the 0v rail. In our project, we have connected the LED so that the lead to the red chip is on the left and the
green is on the right. This means the display is very similar to driving 18 separate LEDs. This allows a
scanning routine with a "run-of-three." Since we do not have enough outputs on the micro to drive all the
LEDs at the same time, we need to introduce a drive method called "multiplexing." This involves turning
on one row at a time and repeating the process at a rate that cannot be detected by the eye. The effect is to
produce a display that can be fully illuminated with any LED producing any of the three colours. As each
row is turned on, six outputs from the micro take the six elements of the three LEDs to the positive rail, via
current-limiting resistors. Each line for the micro can only supply 25mA and if each LED is illuminated
for 33% of the time, the average current will be about 8mA. The brightness of a LED can be produced in
two different ways. It can be constantly illuminated with a current or pulsed with a higher current for a
short period of time.
In our case, the pulse of 25mA for a duty cycle of 33% is equivalent to a constant current of not 8mA but
about 12mA and this is sufficient to give a very good output brightness.
Thus we will have no problem with the illumination of the display.
How To Play:-
When the project is switched on, the ATTRACT MODE is displayed.
Push button "A" to cancel the effect and introduce an orange flashing cursor.
By pushing button A, the cursor will move across the display. Push button B to change the cursor into
a red LED to indicate your move.
The computer will then make its move and show a green LED on the display.
Push button A again to bring the cursor onto the display. Push "A" again to increment the position for your
next "X." The computer will then make its move.
Continue in the way to complete the game.
The "Player Wins" or "Computer Wins" LED will turn on to indicate a winner. If both LEDs turn on the
game is a draw.
Nine locations, from 31h to 39h, correspond to the nine squares on the board. The program consists
of a Main routine that is constantly looping. It scans the display and illuminates the LEDs according to
values in memory locations 31h to 39h. If a location has 01, a red LED on the display is illuminated. If the
value is 04, a green LED is illuminated. If the file holds 05, both red and green are illuminated to produce
ORANGE. The display is scanned by outputting a HIGH to LEDs on six lines of Port B. RB0, RB1, RB2,
RB3, RB4 and RB5. These 6 LEDs represent the red and green elements of the top three bi-coloured
LEDs. A single sinking transistor takes these LEDs to the 0v rail. The transistor is turned off and
the information for the middle three bi-coloured LEDs is outputted on the 6 lines of Port B. The middle
transistor is then turned on and the elements are illuminated. This is continued for the lower 3 LEDs. By
repeating the process very rapidly, the whole display is illuminated.
Conclusion:-
In this project, we have seen that the game Tic Tac Toe, how it works and which microcontroller is
required for that. The microcontroller we have chosen is a PIC16F628. This is one of the latest low-cost
micro's on the market and is an ideal starting-point for beginners to the "art of programming."
Debugging (fault-finding) a program is one of the most difficult things to do in the program of this
game. Only mouse interface is implemented, keyboard is not activated in the game. This game is mostly
used for entertaining also used in many technical events.
References:-
1. The report submitted by Sam Duffy as part requirement for the degree of M Sc in Media Arts
and Technology at the University of London. 2. The
report submitted by Anil Kumar TO Department of Computer Science and Engineering
Lovely Professional University Phagwara
3. Book - H.M. Deitel and P. J. Deital, Java How to program: Sixth Edition
Herbert Schildt, The Complete Reference: Fifth edition
4. Book- Tomlinson C. (2003). Fulfilling the Promise of the Differentiated
Class room Alexandria, VA: Association for Supervision and
Curriculum Development, (ASCD)
5. http://talkingelectronics.com
6. www.google.co.in