You are on page 1of 18

Tic-Tac-Toe Game

ABSTRACT:
TIC-TAC-TOE is a very simple two-player game. So only two players can play at a time. This game is also
known as Noughts and Crosses or Xs and Os game. One player plays with X and the other player plays with
O. In this game, actually there is a board of nxn squares. But, in our game we have a board consisting of a
3x3 grid.

The game will toggle between the players by giving the chance for each player to mark their move.
When one of the players make a combination of 3 same markers in a horizontal, vertical or diagonal line
then we will display which player has won, whether X or O based on their arrangement. In this project, we
implement a 3x3 tic-tac-toe game on the bread board using number pallet. We use number pallet for entering
the players choice to place their object.

The game is designed so that two players can play tic-tac-toe by entering the number in which block
they want to place their object. As the player enters the number, the object gets displayed on the board by
the given instructions. If the place is already filled, it gives an instruction to fill in another place. After
completion of a player’s turn the chance will be moved to another player. If all the places in the board have
been filled, then the game ends with a tie.

1
CONTENTS
S.No TOPIC PAGE.No

1. INTRODUCTION OF TIC – TAC – TOE 3


1.1 Introduction 3
1.2 Aim 3
1.3 Objective 3

2. THEORITICAL ANALYSIS 3
2.1 Existing System 3
2.2 Proposing System 3
2.3 Theory of the Game 3
2.3.1 Core Logic 4
2.3.1.1.First move 4
2.3.1.2.Second move 4
2.3.1.3.Third and Fourth move 6

3. ANALYSIS AND DESIGN OF TIC – TAC – TOE 7


3.1 System Requirements 7
3.1.1.Hardware Requirements 7
3.1.2.Software Requirements 7
3.2.Design 7
3.3.Data Flow Diagram 8

4. IMPLEMENTATION 9
4.1.Source code 9
4.2.Methods used 15

5. RESULT AND DISCUSSION 15


5.1. Result 15

6. CONCLUSION AND FUTURE ENHANCEMENT 17


6.1. Conclusion 17
6.2. Future Enhancement 17
6.3. Limitations 17

7. REFERENCES. 17

2
1.INTRODUCTION OF TIC – TAC – TOE GAME :

1.1. INTRODUCTION :
→Tic-tac-toe is a simple, two-player game that, if played optimally by both players, will always result
in a tie. The game is also called noughts and crosses or Xs and Os.

→Tic-tac-toe is a game that is traditionally played by being drawn on paper, and it can be played on a
computer or on a variety of media.

→In this game, there is a game board with nxn squares. But, in our project it is 3x3 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 3x3 grid.

1.2.AIM :

The aim of the project is to develop a Tic – Tac – Toe game for mobile device. The game is
supposed to consists of two parts, one a single player game (a player against the system), and the
other a multi-player game (two players on the device against each other).

1.3.OBJECTIVE :

• To be familiar with Object Oriented Programming(OOP).


• To learn about android device and android app development.
• To learn process of project development.
• To implement the GUI algorithms in digital device.
• To eliminate the use of paper for playing “TIC – TAC – TOE”.

2. THEORETICAL ANALYSIS :

2.1.EXISTING SYSTEM :
Tic-Tac-Toe (or Noughts and crosses, Xs and Os) is a pencil-and-paper game for two players, O and X, who
take turns marking the spaces in a 3 x 3 grid. The player who succeeds in placing three respective marks in a
horizontal, vertical or diagonal row wins the game.

2.2.PROPOSED SYSTEM :
In this project, we create a 3x3 tic-tac-toe game in LabVIEW. The system is designed so that two players
can play a game of tic-tac-toe using LabVIEW software. The program will contain a display function and a
select function to place the symbol as well as toggle between the symbols allowing each player a turn to play
the game. The program will update after each player makes their move and will check for the conditions of
the game as it goes on.

2.3.THEORY OF THE 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
3
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.

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, 7
e) 2, 5, 8 f) 3, 6, 9
h) 1, 5, 9 i) 3, 5, 7

2.3.1.Core Logic –
2.3.1.1.First move:
a) If the center is free, get the center.
b) Otherwise, get any of the corners.

2.3.1.2.Second move:
a) Block the opponent from winning.
b) Option for winning by applying the following logic: If the center is occupied by player-1, get any of the
corners.
4
Otherwise, the following cases happen:

Case 1:

If any situation arises like the above diagram, then the player-2 sets its symbol any one of the position
among 2, 4, 6 and 8.

Case 2:

If any situation arises like the above diagrams, then the player-2 sets its symbol at any position among 4 and
6.

Case 3:

5
If any situation arises like the above diagrams, then the player-2 sets its symbol at any position among 2 and
8.

Case 4:

If any situation arises like the above diagrams, then the player-2 sets its symbol at any position among 1, 3,
7 and 9.

2.3.1.3.Third and fourth move:


a) Option for winning.
b) Block user from winning.
c) Randomly play a move.

6
3.ANALYSIS & DESIGN OF TIC-TAC-TOE :

3.1.SYSTEM REQUIRMENTS:

3.1.1.Hardware Requirements:

• RAM: 4GB and Higher

• Processor: Intel i3 and above

• Hard Disk: 500GB: Minimum

3.1.2.Software Requirements:

• OS: Windows or Linux


• Python IDE : python 2.7.x and above
• Pycharm IDE Required, jupyter notebook
Language : Python

3.2.DESIGN:
Implementation of the Tic-Tac-Toe game is done using GUI. This is done using tkinter. A landing page
containing selection buttons is created. Selection buttons include single player or multiplayer. The user
should select whether single player or multiplayer. A game board containing nine tiles to play the game
along with other details (i.e. playing with a system or another player , whose turn etc.) should be created.
The player is allowed to press the tile and check the status of the game (i.e. Tie game, anyone of the players
won the match or the game is still running). At last a message is displayed showing who won the match.

Functions such as gameboard_pc(), gameboard_pl(), get_text_pc(), get_text(), pc(), winner(), isfree(),


isfull() are used in the implementation.

7
3.3.DATA FLOW DIAGRAM :

8
4.IMPLEMENTATION :

4.1.SOURCE CODE :

9
10
11
12
13
14
4.2.METHODS USED:

→Tkinter is the standard GUI library for python. It provides a good object-oriented interface to Tk GUI
toolkit. We import tkinter module.

→gameboard_pc() and gameboard_pl() will create the another geometry to play the game. It will add 9
buttons on 3×3 board of the game (Three rows of buttons containing three buttons each).

→get_text_pc() and get_text() functions will put the text on buttons as it pressed.

→pc() function will decide the next move of the system.

→winner() function will check whether the player won the match or not.

→isfree() function will check whether the player can put it’s a coin or not.

→isfull() function will check the board is full or not.

5.RESULT AND DISCUSSION :

5.1.RESULT :

For Single-Player : (Human v/s computer)

15
For Multi-Player : (Player1 v/s Player2)

16
6.CONCLUSION & FUTURE ENHANCEMENT :

6.1.CONCLUSION:

➔ By this project, we are much aware of Object Oriented Programming.


➔ We also come to know about GUI.
➔ We learnt about the android devices and app development
➔ We also learnt project development.

6.2.FUTURE ENHANCEMENT:

• By next project, in android development we would like to learn the OpenGI 2D graphics which can
be implements in the application which will improve the working and presentation of the application.
• Also we would like to implement a 4x4 board game.
• We would to make the game to play from two different computers at a time in multi-player option.

6.3.LIMITATIONS:

• The code is lengthy.


• The game cannot be played by one or more than 2 players.
• It is not a high level game
• It doesn’t contain levels.

7.REFERENCES :

→Tic-Tac-Toe game in wikipidia, http://en.wikipedia.org/wiki /Tic-tac-toe


→Introduction to LabVIEW– user manual – National Instruments http://www.ni.com/
→ S. C. Fok and E. K. Ong. A High School Project on Artificial Intelligence in Robotics, Artificial
Intelligence in Engineering, Vol. 10, No. 1, 1996, pp. 61-70.
→ J. Grim, P. Somol and P. Pudil. Probabilistic Neural Network Playing and Learning Tic-Tac-Toe,
Pattern Recognition Letters, Vol.26, No. 12, 2005, pp. 1866-1873.
→ R. L. Citrenbaum. Strategic Pattern Generation: A Solution Technique for a Class of Games,
Pattern Recognition, Vol. 4, No. 3, 1972, pp. 317-329.
→ S. Yakowitz. A Statistical Foundation for Machine Learning, with Application to Go- Moku,
Computers and Mathematics with Applications, Vol. 17, No. 7, 1989, pp. 1095- 1102
→ iPhone Simple Tic-Tac-Toe Implementation, http://www.vworker.com/RentACoder/misc
BidRequests/ ShowBidRequest.asp?lngBidRequestId=1622905
→ Tic Tac for Android, http://www.androidappshome.com/tic-tac-toe-free-android-57.html.

17
→ Stephen Mann and Matthew Netsch, "A parallelEmbedded Neural Network for an Intelligent
Turn-Based Engine", http://www.samduffysinger.pwp.blueyonder.co.uk/
Project%20Outline%20TicTacToe.pdf
→ Shahzeb Siddiqui , Francis Mutuc and Nicholas Schmidt, "Designing a 5x5x5 Tic-Tac-Toe Game
using a Neural Network with Backpropagation with a Twist”,
http://www.personal.psu.edu/fcm5007/eportfolio/AINeural Networks.pdf
→ Pinaki Chakraborty, Artificial Intelligence Based Strategies to Play the Tic -Tac-Toe Game,
Journal of Technology and Engineering Sciences, Vol 1, No. 1 January –June 2009
→ J N Leaw and S A Cheong, Strategic insights from playing quantum tic-tac-toe, Journal of
Physics A: Mathematicaland Theoretical Volume 43 Number 45, 2010
→ Soedarmadji, Decentralized Decision Making in the Game of Tic-tac-toe, IEEE Symposium on
Computational Intelligence and Games, May 2006
→ Edward P. Vogel, Tic tac toe game using an optically routed gate array, Proc. SPIE 2863, Current
Developments in Optical Design and Engineering VI, 407, Nov 1, 1996
→ Alauddin Al-Omary, Machine- Human Tic-Tac game based on Microcontroller Technology,
International Journal of Computer and Information Technology (ISSN:2279 – 0764) Volume 02–
Issue 05, September 2013

18

You might also like