Project TIC Tak Toe Using Python
Project TIC Tak Toe Using Python
INTRODUCTION
One of the most universally played childhood games is TIC TAC TOE. An
interactive TIC TAC TOE game is developed where two players will be
able to play against each other in a suitable GUI by using proper mouse
movements. This game will start by showing a simple display, prompt the
user for a move and then prints the new board. The board looks like a
large hash symbol (#) with nine slots that can each contain an X, an O, or
a blank. There are two players, the X player and the O player. By default,
player1 (the O player) takes the initiative. The game will end in two
situations: a win, when one player gets three in a row, horizontally,
vertically or diagonally. A draw, when there are no remaining places to
choose and neither of them has won. Here are some rules for the game:
If all nine squares are filled and none of the players have three in
a row, the game is a draw.
1. PROJECT DESCRIPTION
PROBLEM DEFINITION:
The project consists of developing and implementing
a computer program that plays TIC TAC TOE against
another player. This developed system will reduce
the manual work that is for playing a game you’ve not
to carry a pen or a pencil and a few sheets of papers
on your pocket all the time. The system can able to
provide hundreds or thousands of TIC TAC TOE
game without any interruption.
NEW BOARD: The main objective of this module is to create a new board
that consists of three rows and the columns. The board is nothing but a 2
Dimensional three by three matrix and we’ll create the matrix by using list of
strings.
GAMEOVER SCREEN: This module is concerned with displaying the result
according to the outcome on the screen. It takes outcome as an object and displays
the appropriate result.
CLICK: This module handles most of the game logic. A tkinter application
runs most of its time inside an event loop, which is entered via the main loop
method
NEW MOVE:
This module is concerned with pacing the X’s and O’s in the selected cells on the board. It
receives the current player
HAS WON:
This module is concerned with checking for the winner and returns the result to an
appropriate calling function. In the click module, we’ve already converted the grids
into pixels and store them into some variables.
IS A DRAW:
In this module, we’re just checking the result is a tie or not. The result is a tie when all
the boxes/cells are filled. Checking whether it is a draw is fairly straightforward.
EXIT:
This module is used for closing the root window permanently. In this
module we’ve passed event as an argument based upon this event the
window can be closed.
self.destroy()
Functionalities
The purpose of this functionalities is to capture all the
requirements by which the user can play a game of tic-
tac-toe in Graphical User Interface as well as they can
develop a logic that what is actually happening. Some
functionalities used for this project are
creating functions:
Can define functions of your own
Functions let you to break up code into manageable
chunks.
Eg new_move(), move(), exit().
Defining a Function:
Functions make programs easier to read, write and
maintain.
Function definition: Code that defines what a new
function does.
Function header: First line of a function definition
Give function name that conveys what it does or
produces
Eg def title_screen():
print "Welcome to the world's greatest game!"
Documenting a Function:
Docstring: String that documents a function
Eg: def exit():
"""Display game instructions."""
print "Are you sure of leaving this game"