Documente Academic
Documente Profesional
Documente Cultură
at
BACHELOR OF TECHNOLOGY
JUN-JULY, 2019
SUBMITTED BY:
CANDIDATE'S DECLARATION
I “Chetan Kumar” hereby declare that I have undertaken six weeks Industry Oriented Project
Training at “Baba Banda Singh Bahadur Engineering College, Fatehgarh Sahib” during a
period from 03/06/2019 to 12/06/2019 in partial fulfilment of requirements for the award of
presented in the training report submitted to Department of Computer Science and Engineering
Secondly, I would like to thank Akshay Khatri, my mentor, for his valuable guidance
throughout the industrial training period. His teachings have been enlightening and form the
I am also forever grateful to the college staff and my parents for their constant support and help
whenever I needed.
Finally, I would like to thank the Department of Computer Science Engineering of BBSBEC,
Fatehgarh Sahib for giving me this opportunity to work on the major project and put my skills
Certified by Company/Industry/Institute. i
Candidate’s Declaration ii
Abstract iii
Acknowledgement iv
List of Figures v
List of Tables vi
1.1 1
1.2 4
1.3
1.4
1.1 Introduction
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 is presented in the form
of a nine square grid similar to a tic-tac-toe board and students may be expected to complete from
one to “three in a row”. The activities vary in content, process, and product and can be tailored to
address different levels of student readiness, interests, and learning styles. The center square may be
left open for the student to select an activity of their own. Tic-tac-toe activities may be given to
every student in the class, higher ability students for extension activities, or lower students for
review and practice. Involvement in this strategy encourages independent learning. Teachers should
check in with students periodically and require students to keep a log of their progress.
Tic-tac-toe is a casual strategy game for everyone. It is easy to teach, and the player can play this
game almost everywhere. Because it only requires a writing tool and a writable surface.
The game is to be played between two people (in this program between HUMAN and
COMPUTER).
One of the player chooses ‘O’ and the other ‘X’ to mark their respective cells.
The game starts with one of the players and the game ends when one of the players has
one whole row/ column/ diagonal filled with his/her respective character (‘O’ or ‘X’).
A player can play perfect tic-tac-toe (win or draw) given they move according to the highest
1. Win: If the player has two in a row, play the third to get three in a row.
2. Block: If the opponent has two in a row, play the third to block them.
Option 1: Create two in a row to force the opponent into defending, as long as it
doesn't result in them creating a fork or winning. For example, if "X" has a corner,
"O" has the center, 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.)
b. Option 2: If there is a configuration where the opponent can fork, block that fork.
6. Opposite corner: If the opponent is in the corner, play the opposite corner.
The first player, whom we shall designate "X", has 3 possible positions to mark during the first
turn. Superficially, it might seem that there are 9 possible positions, corresponding to the 9
squares in the grid. However, by rotating the board, we will find that in the first turn, every
corner mark is strategically equivalent to every other corner mark. The same is true of every edge
mark. For strategy purposes, there are therefore only three possible first marks: corner, edge, or
center. Player X can win or force a draw from any of these starting marks; however, playing the
corner gives the opponent the smallest choice of squares which must be played to avoid losing.
The second player, whom we shall designate "O", must respond to X's opening mark in such a
way as to avoid the forced win. Player O must always respond to a corner opening with a center
mark, and to a center opening with a corner mark. An edge opening must be answered either with
a center mark, a corner mark next to the X, or an edge mark opposite the X. Any other responses
will allow X to force the win. Once the opening is completed, O's task is to follow the above list
of priorities in order to force the draw, or else to gain a win if X makes a weak play.
3. Implementation
Then each player taking turn draw their symbol on a space from that nine possible
spaces.
The one who met the winning condition first win. If after nine possible spaces are
Goal:
The goal of this game is to be the first one who draws three of the player’s symbol to form one of
Winning Condition:
Game Rules
1. Traditionally the first player plays with "X". So you can decide who wants to go with "X"
and who wants go with "O".
2. Only one player can play at a time.
3. If any of the players have filled a square then the other player and the same player
cannot override that square.
4. There are only two conditions that may match will be draw or may win.
5. The player that succeeds in placing three respective marks (X or O) in a horizontal,
vertical or diagonal row wins the game
Most of the research nowadays is focused towards problems that deal with complexity or are
influenced by some kind of random events. Interesting about these problems is that if they are
deterministic, then a solution is expected to exist, at least a theoretical one. These problems are
often inspired by games, such as mathematical games (ex. Tic-Tac-Toe, Chess). On the other hand
the point of randomness involved in these problems increases the difficulty of prediction on the
possible solution, or in some situations outcome. This is thy, there are certain methods of operations
devised, that in turn give some supplementary information to a decision maker. In most of the cases,
the probability distribution of an even which took place randomly, it is possible to be affected by
prior events.
The game usually begins with the X player, and the player who will manage to place three
respective marks (in any direction, i.e. in a horizontal, vertical, or diagonal row) wins the game.
This basic version of the game is rather simple, what allows the game to be used as a useful tool in
combinatorial game theory, as well as a branch of artificial intelligence that deals with the searching
of game trees (Beck, 2008). Using game theory there are few approaches that can be undertaken:
Minimax strategies decide a stable solution – useful if the opponent makes the wrong play
Even though, game theory researches are made on the possible playing strategies, they might not be
employed in real life when playing a game, because:
There might be too many strategies to enumerate (this number is simply too large to be estimated).
If player 1 selected X then O has to be automatically allotted to the mobile device as a second
player, and vice versa.
The player has an option to choose the small game grid out of 4 small tic-tac-toe games.
If player X marked horizontally or vertically or diagonally of his symbol “X ” in a row, then player X
won that small match.
Finally, which player won the maximum small games will be declared as winner of the tic-tac-toe
game.
Multi-player game
Using Bluetooth as communication channel the two players should play Tic-Tac-Toe game from
different mobiles.
Once both players connected together, then first player will start the game of choosing his symbol
as X or O.
Player2 have option to choose the small game grid out of 4 small tic-tac-toe games.
After grid selection both players will play tic-tac-toe game in that small grid.
If player X marked horizontally or vertically or diagonally of his symbol “X ” in a row, then player X
won that small match.
That small grid is marked with X and Player1 awarded 1 point, screen should zoom out and have to
display whole main game grid and now player who won the previous game will have the choice to
choose on which grid have to be select to play remaining game.
This process will be repeated until the whole Four (4) small games grids marked with X, or O, or T.
Finally which player won the maximum small games will be declared as winner of the tic-tac-toe
game. then game ends.
3. Background Research
In this section the Tic-Tac-Toe game will be discussed in details. At the outset, the basic rules of
the game are going to be covered. Then, there will be a review on existing Tic-Tac-Toe games,
which in turn will lead to discussion about the existing models of this game and the proposed model
of this work. Finally, this section is going to be concluded with a technology research. concentrated
3.1 Basic Rules of Tic-Tac-Toe game
The basic Tic-Tac-Toe game consists of two players, X and O, who take turns marking the spaces
in a 3Ã-3 grid (Crowley, 1993; Gardner, 1998). The game usually starts with the X player, and the
player who will manage to place three respective marks wins the game. The marks can be placed
in any direction, i.e. in a horizontal, vertical, or diagonal row. This basic version of the game is
rather simple and very often leads to draw. This simplicity allows the game to be used as a useful
tool in combinatorial game theory, as well as a branch of artificial intelligence that deals with the
searching of game trees (Beck, 2008).
In order to find a winning strategy, in theory all the paths could be explored. However, in practice
this is not easy because the total number of strategies can be calculated a double exponential
function of the size of the board. For example, a 3-dimensional 5Ã-5Ã-5 version of Tic-Tac-Toe,
has about 3125 positions. This is because each one of the 53 cells has 3 options:
In order to play a perfect tic-tac-toe game, i.e. a win or a draw, the player can play given they move
consistent with the uppermost possible moves.
Strategy
A player can play a perfect game of tic-tac-toe (to win or at least, draw) if each time it is his turn to play, he chooses the first available
move from the following list, as used in Newell and Simon's 1972 tic-tac-toe program.[16]
6. Win: If the player has two in a row, they can place a third to get three in a row.
7. Block: If the opponent has two in a row, the player must play the third themselves to block the
opponent.
8. Fork: Create an opportunity where the player has two ways to win (two non-blocked lines of 2).
9. Blocking an opponent's fork: If there is only one possible fork for the opponent, the player should
block it. Otherwise, the player should block any forks in any way that simultaneously allows them
to create two in a row. Otherwise, the player should create a two in a row to force the opponent into
defending, as long as it doesn't result in them creating a fork. For example, if "X" has two opposite
corners and "O" has the center, "O" must not play a corner in order to win. (Playing a corner in this
scenario creates a fork for "X" to win.)
10. Center: A player marks the center. (If it is the first move of the game, playing on a corner gives the
second player more opportunities to make a mistake and may therefore be the better choice;
however, it makes no difference between perfect players.)
11. Opposite corner: If the opponent is in the corner, the player plays the opposite corner.
13. Empty side: The player plays in a middle square on any of the 4 sides.
Why python
The game is automatically played by the program and hence, no user input is
needed. Still, developing a automatic game will be lots of fun. Let’s see how to
do this.
numpyand random Python libraries are used to build this game. Instead of asking the
user to put a mark on the board, code randomly chooses a place on the board
and put the mark. It will display the board after each turn unless a player wins.
If the game gets draw, then it returns -1.
Explanation :
play_game() is the main function, which performs following tasks :
2. Current System
Playing TicTacToe on paper is perhaps one of the oldest means of playing a two-player
logic game; it is time to bring this game to the 21st century. Existing paper and pencil
methods are inefficient, especially considering the many variations that have been
proposed. One cannot play TicTacToe at a distance (unless reading moves over a
telephone counts).
3. Proposed System
3.1 Overview
To make T4 a reality, we need to design a client/server architecture where the server
maintains the tournament and clients join to participate. There is no mechanism for
clients to "discover" available tournaments, clients must know in advance the
tournament to which to connect (which is determined by a machine name and port). In
our project, we expect that tournaments can host up to 64 active users
18. The tournament director should be able to create a tournament and oversee its
execution.
19. players should be able to connect to the tournament and participate as arranged
by the tournament director.
window=Tk()
window.geometry("400x300")
lbl=Label(window,text="Tic-tac-toe Game",font=('Bold','15'))
lbl.grid(row=0,column=0)
lbl=Label(window,text="Player 1: X",font=('Bold','10'))
lbl.grid(row=1,column=0)
lbl=Label(window,text="Player 2: O",font=('Bold','10'))
lbl.grid(row=2,column=0)
def clicked1():
global turn
if turn==1:
turn =2;
btn1["text"]="X"
elif turn==2:
turn=1;
btn1["text"]="O"
check();
def clicked2():
global turn
if btn2["text"]==" ":
if turn==1:
turn =2;
btn2["text"]="X"
elif turn==2:
turn=1;
btn2["text"]="O"
check();
def clicked3():
global turn
if btn3["text"]==" ":
if turn==1:
turn =2;
btn3["text"]="X"
elif turn==2:
turn=1;
btn3["text"]="O"
check();
def clicked4():
global turn
if btn4["text"]==" ":
if turn==1:
turn =2;
btn4["text"]="X"
elif turn==2:
turn=1;
btn4["text"]="O"
check();
def clicked5():
global turn
if btn5["text"]==" ":
if turn==1:
turn =2;
btn5["text"]="X"
elif turn==2:
turn=1;
btn5["text"]="O"
check();
def clicked6():
global turn
if btn6["text"]==" ":
if turn==1:
turn =2;
btn6["text"]="X"
elif turn==2:
turn=1;
btn6["text"]="O"
check();
def clicked7():
global turn
if btn7["text"]==" ":
if turn==1:
turn =2;
btn7["text"]="X"
elif turn==2:
turn=1;
btn7["text"]="O"
check();
def clicked8():
global turn
if btn8["text"]==" ":
if turn==1:
turn =2;
btn8["text"]="X"
elif turn==2:
turn=1;
btn8["text"]="O"
check();
def clicked9():
global turn
if btn9["text"]==" ":
if turn==1:
turn =2;
btn9["text"]="X"
elif turn==2:
turn=1;
btn9["text"]="O"
check();
flag=1;
def check():
global flag;
b1 = btn1["text"];
b2 = btn2["text"];
b3 = btn3["text"];
b4 = btn4["text"];
b5 = btn5["text"];
b6 = btn6["text"];
b7 = btn7["text"];
b8 = btn8["text"];
b9 = btn9["text"];
flag=flag+1;
if b1==b2 and b1==b3 and b1=="O" or b1==b2 and b1==b3 and b1=="X":
win(btn1["text"])
if b4==b5 and b4==b6 and b4=="O" or b4==b5 and b4==b6 and b4=="X":
win(btn4["text"]);
if b7==b8 and b7==b9 and b7=="O" or b7==b8 and b7==b9 and b7=="X":
win(btn7["text"]);
if b1==b4 and b1==b7 and b1=="O" or b1==b4 and b1==b7 and b1=="X":
win(btn1["text"]);
if b2==b5 and b2==b8 and b2=="O" or b2==b5 and b2==b8 and b2=="X":
win(btn2["text"]);
if b3==b6 and b3==b9 and b3=="O" or b3==b6 and b3==b9 and b3=="X":
win(btn3["text"]);
if b1==b5 and b1==b9 and b1=="O" or b1==b5 and b1==b9 and b1=="X":
win(btn1["text"]);
if b7==b5 and b7==b3 and b7=="O" or b7==b5 and b7==b3 and b7=="X":
win(btn7["text"]);
if flag ==10:
window.destroy()
def win(player):
messagebox.showinfo("Congratulations", ans)
window.destroy() # is used to close the program
btn1.grid(column=1, row=1)
btn2.grid(column=2, row=1)
btn3.grid(column=3, row=1)
btn4.grid(column=1, row=2)
btn5.grid(column=2, row=2)
btn6.grid(column=3, row=2)
btn7.grid(column=1, row=3)
btn9.grid(column=3, row=3)
window.mainloop()
LP 15th
System Design:
Then we began with the design phase of the system. System design is a solution, a “HOW
TO” approach to the creation of a new system. It translates system requirements into
ways by which they can be made operational. It is a translational from a user oriented
and procedural details necessary for the implementation. Here we use Flowchart to
supplement the working of the new system. The system thus made should be reliable,
durable and above all should have least possible maintenance costs. It should overcome
all the drawbacks of the Old existing system and most important of all meet the user requirements.
FUTURE SCOPE OF THE PROJECT
Our project will be able to implement in future after making some changes and
modifications as we make our project at a very low level. So the modifications that can
In future one change can be done by adding the fingerprints of the persons of which the
address is entered.And one more major change which can be done in this project is that to
add the snaps of the person of which the address is entered.We can also add or subtract
In the long-term, the success of the T4 project is based on a future ability to host as many T4
tournaments as one would ever want, and enable T4 clients to be able to rapidly find available
tournaments to connect to. However, the current objectives limit our scope to a well-known
tournament being played on a well known machine, to which T4 clients connect.