Sunteți pe pagina 1din 24

A REPORT OF SIX WEAKS INDUSTRIAL TRAINING

at

BBSBEC, Fatehgarh Sahib

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE AWARD


OF THE DEGREE OF

BACHELOR OF TECHNOLOGY

(Computer Science and Engineering)

JUN-JULY, 2019

SUBMITTED BY:

NAME : CHETAN KUMAR

UNIVERSITY ROLL NO. : 170280228

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


BABA BANDA SINGH BAHADUR ENGINEERING COLLEGE, FGS

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

degree of B.Tech. (Computer Science and Engineering) at BABA BANDA SINGH

BAHADUR ENGINEERING COLLEGE, FATEHGARH SAHIB. The work which is being

presented in the training report submitted to Department of Computer Science and Engineering

at BABA BANDA SINGH BAHADUR ENGINEERING COLLEGE, FATEHGARH SAHIB

is an authentic record of training work.

Signature of the Student

The industry oriented project training Viva–Voce Examination of__________________ has


been held on ____________ and accepted.

Signature of Internal Examiner Signature of External Examiner


Abstract
Acknowledgement
First of all I record my sincere thanks Maj. Gen.(Dr) Gurcharan Singh Lamba, Head of

Department of Computer Science Engineering, BBSBEC, Fatehgarh Sahib, for providing me

with the opportunity and supporting me on every stage of this project.

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

backbone of this major project.

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

and knowledge to best use.


CONTENTS

Topic Page No.

Certified by Company/Industry/Institute. i

Candidate’s Declaration ii

Abstract iii

Acknowledgement iv

List of Figures v

List of Tables vi

Definitions, Acronyms and Abbreviations. Vii

CHAPTER 1 INTRODUCTION TO ORGANIZATION(s) 1-19

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.

1.2 What is Tic Tac Toe?


Tic-tac-toe is not a very challenging game for human beings. If you’re an enthusiast, you’ve
probably moved from the basic game to some variant like three dimensional tic-tac-toe on a larger
grid. If you sit down right now to play ordinary three-by-three tic-tac-toe with a friend,what will
probably happen is that every game will come out a tie. Both you and your friend can probably play
perfectly, never making a mistake that would allow your opponent to win. But can you describe
how you know where to move each turn? Most of the time, you probably aren’t even aware of
alternative possibilities; you just look at the board and instantly know where you want to move.
That kind of instant knowledge is great for human beings, because it makes you a fast player
But it isn’t much help in writing a computer program. For that, you have to know very explicitly
what your strategy is.

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.

Vandalism is not recommended.

Players: Two players

Time estimation: one – two minutes

1.3 Backend Functionally

How Game Work

The functionality that hoe game work? Is given in detail.

Rules of the Game:

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

possible move from the following table.

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.

3. Fork: Create an opportunity where you can win in two ways

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.

5. Center: Play the center.

6. Opposite corner: If the opponent is in the corner, play the opposite corner.

7. Empty corner: Play in a corner square.

8. Empty side: Play in a middle square on any of the 4 sides.

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

3.1 How to play?

Use any method to find who will start first.

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

used, but no one wins, that game is a draw.

Goal:

The goal of this game is to be the first one who draws three of the player’s symbol to form one of

these winning conditions.

Winning Condition:

These are the acceptable win condition of this game.

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

Minimax strategies do not decide a stable solution – using a probability distribution

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).

Players are not always rational.

ThereThere might be more than two players.

Aim and Objectives


The aim of this project is to develop a Tic-Tac-Toe game for mobile device. The game is supposed
to consist of two parts, one a single player game (a player against a system), and the other a multi-
player game (two players on their mobile devices, playing against each other). In order to
accomplish these, the following objectives were defined.

Single player game


The player should play Tic-Tac-Toe game on his mobile device.

The player should have option to edit his name.

The player will start the game of choosing his symbol as X or O.

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.

Players should have options to edit his name.

Once both players connected together, then first player will start the game of choosing his symbol
as X or O.

If player 1 selected X then O has to be automatically allotted to player 2.


Then main game grid has to display in both mobiles.

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:

Marked by the first player,Marked by the second player, orUnmarked.

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.

12. Empty corner: The player plays in a corner square.

13. Empty side: The player plays in a middle square on any of the 4 sides.

Why python

Tic-tac-toe is a very popular game, so let’s implement an automatic Tic-tac-toe


game using 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 :

14. Calls create_board() to create a 9×9 board and initializes with 0.


15. For each player (1 or 2), calls the random_place() function to randomly choose a
location on board and mark that location with the player number, alternatively.
16. Print the board after each move.
17. Evaluate the board after each move to check whether a row or column or a diagonal
has the same player number. If so, displays the winner name. If after 9 moves, there
are no winner then displays -1.
1.6 Overview

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

3.2 Functional Requirements


T4 supports two types of 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.

Each of these users has the following capabilities:

3.2.1 Tournament Director capabilities


The tournament director shall be able to execute the tournament server on a given
machine (and valid port number, the default being 30303). There is an administrative
client (made available to the tournament director) where the director can securely login
to the tournament server to request the following functions:

1 shutdown the tournament (which ends the server)


2 start the tournament by determining the number of rounds to schedule, based upon
the number of players connected to the tournament server; there must be at least
16 players to form a working tournament
3 initiate a round in the tournament (by randomly assigning an even number of
players to a set of tables, and randomly assigning the known TicTacToe variations to
the tables)
4 monitor the progress of an existing tournament (including the board state of all
available tables, which player's turn is active, the status of the timers on each table)
and this information should be updated 'in near real-time' as the individual tables
proceed.
5 kick a player out of the tournament (all future games by that player to be forfeited)

3.2.3 Player capabilities


The player shall be able to execute a T4 client that can securely login to the tournament
server to request the following functions:

1. join tournament, to become eligible to be selected by the tournament director to


play
2. display graphically the state of a table within which the player is participating
3. select (valid) moves to be played

from tkinter import *

from tkinter import messagebox

window=Tk()

window.title("Welcome to The Gaming world TIC-Tac-Toe ")

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)

turn=1; #For first person turn.

def clicked1():

global turn

if btn1["text"]==" ": #For getting the text of a button

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:

messagebox.showinfo("Tie", "Match Tied!!! Try again :)")

window.destroy()

def win(player):

ans = "Game complete " +player + " wins ";

messagebox.showinfo("Congratulations", ans)
window.destroy() # is used to close the program

btn1 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked1)

btn1.grid(column=1, row=1)

btn2 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked2)

btn2.grid(column=2, row=1)

btn3 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked3)

btn3.grid(column=3, row=1)

btn4 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked4)

btn4.grid(column=1, row=2)

btn5 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked5)

btn5.grid(column=2, row=2)

btn6 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked6)

btn6.grid(column=3, row=2)

btn7 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked7)

btn7.grid(column=1, row=3)

btn8 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked8)
btn8.grid(column=2, row=3)

btn9 = Button(window, text=" ",bg="yellow",


fg="Black",width=3,height=1,font=('Helvetica','20'),command=clicked9)

btn9.grid(column=3, row=3)

window.mainloop()

##Tic tac toe

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

document to a document oriented programmers. For that, it provides the understanding

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

be done in our project are:

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

details of the individual.

4. Provide an extensible infrastructure capable of hosting a tournament (with at least 16


players) playing any number of TicTacToe variations
5. Enable prospective TicTacToe players to receive tutoring on different TicTacToe variations
(as prepared by the authors of the TicTacToe variations)
6. Store information persistently for users that connect to the hosting site, so they can return to
play at any time

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.

S-ar putea să vă placă și