0% found this document useful (0 votes)
80 views50 pages

Internship Report

The document describes a summer internship project to develop a Tic Tac Toe game in Python. It includes an introduction to the organization where the internship was completed, details of the training received, requirements and design of the Tic Tac Toe system, and screenshots of the implemented game. The goal was to build a two-player Tic Tac Toe game that allows players to alternate turns placing X or O markers until someone wins a row, column, or diagonal, or the board is full to a draw.

Uploaded by

Tanuj Mehra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views50 pages

Internship Report

The document describes a summer internship project to develop a Tic Tac Toe game in Python. It includes an introduction to the organization where the internship was completed, details of the training received, requirements and design of the Tic Tac Toe system, and screenshots of the implemented game. The goal was to build a two-player Tic Tac Toe game that allows players to alternate turns placing X or O markers until someone wins a row, column, or diagonal, or the board is full to a draw.

Uploaded by

Tanuj Mehra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

A

SUMMER INTERNSHIP REPORT

Submitted by

TUSHAR MEHRA
(04914202020)

in partial fulfillment for the award

of the degree of

Bachelor of Computer Application


(2020-23)

JAGANNATH INTERNATIONAL
MANAGEMENT SCHOOL
Vasant Kunj, New Delhi - 110070
(AUG-2022)
CERTIFICATE
ACKNOWLEDGEMENT

In successfully completing this project, many people have helped me. I would
like to thank all those who are related to this project.

I would like to thank Dr. Meenakshi Narula who gave me this opportunity to
work on this project titled "TIC TAC TOE”. I would also like to thank my
teacher Mrs. Priyanka Rattan for helping me with this project. She allowed me
to work on this project.

Finally, I would like to thank my parents and friends who have helped me with
their valuable suggestions and guidance and have been very helpful in various
stages of project completion.

(Tushar Mehra)
(04914202020)
TABLE OF CONTENTS

1. ABSTRACT
2. LIST OF FIGURES
3. Chapter 1 – INTRODUCTION
3.1 About Organization
3.2 Organization mission and vision
3.3 Organization Objectives
3.4 Organization Market Share

4. Chapter 2 – TRAINING DETAIL


4.1 Course Overview
4.2 Course Details
4.3 Course Assignments completion details
4.4 Other details

5. Chapter 3 – SYSTEM STUDY


5.1 Problem Statement
5.2 Project Objectives
5.3 Project Scope
5.4 Need of the system
5.5 System Requirements

6. Chapter 4 – SYSTEM DESIGN


6.1 Introduction
6.2 Design Diagrams
6.2.1 System Flow Charts
6.2.2 Use Case Diagram

7. Chapter 5- SOFTWARE CODING AND IMPLEMENTATIONS


7.1 Introduction
7.1.1 System Coding Environment and Standards Followed
7.1.2 Sample Code Layouts
7.2 Application Screen shots (with data)
8. CONCLUSION

9. BIBLIOGRAPHY

LIST OF FIGURES
Figure 1. Flow chart of system -------------------------------------------------- 20
Figure 2. Use case diagram ------------------------------------------------------ 22
Figure 3. Sample code ------------------------------------------------------------ 24
Figure 4. Sample layout code(i)--------------------------------------------------30
Figure 5. application screenshots------------------------------------------------ 53
Figure 6 TIC TAC TOE in python (i)------------------------------------------54
Figure 7. TIC TAC TOE game in python(ii)----------------------------------- 55

INTRODUCTION
ABOUT ORGANIZATION:

Udemy, Inc. is a for-profit massive open online course (MOOC) provider aimed
at professional adults and students. It was founded in May 2010 by Eren Bali,
Gagan Biyani, and Oktay Caglar.
Students take courses primarily to improve job-related skills Some courses
generate credit toward technical. Udemy has made a special effort to attract
corporate trainers seeking to create coursework for employees of their company.
The headquarters of Udemy is located in San Francisco, US, with hubs in
Denver,
US; Dublin, Ireland; Ankara, Turkey; Sao Paulo, Brazil; and Gurugram, India

Udemy is a platform that allows instructors to build online courses on their


preferred topics. Using Udemy's course development tools, instructors can
upload videos, source code for developers, PowerPoint presentations, PDFs,
audio, ZIP files and any other content that learners might find helpful.
Instructors can also engage and interact with users via online discussion boards
Courses are offered across a wide breadth of categories, including business and
entrepreneurship, academics, the arts, health and fitness, language, music, and
technology Most classes are in practical subjects such as AWS and Azure
training, Excel software or using an iPhone camera. Udemy also offers Udemy
Business (formerly Udemy for Business), enabling businesses access to a
targeted suite of over 7,000 training courses on topics from digital marketing
tactics to office productivity, design management, programming, and more.
With Udemy Business, organizations can also create custom learning portals for
corporate training. For smaller companies, Udemy offers a Udemy Team Plan
that is a limited seat license but identical content to that of Udemy Business.

ORGANIZATION MISSION AND VISION:


Udemy’s mission is to provide flexible, effective skill development to
empowering organizations and individuals.
Udemy Business helps companies achieve critical business outcomes and stay
competitive by offering engaging on-demand, immersive, and cohort-based
learning. With our integrated learning solutions and strategic partnership, we
equip companies with the tools to build a future-ready workforce, increase
employee engagement, and achieve business outcomes. And we tailor learning
to our customer’s needs, so they can deliver the right learning experience to the
right people in the right format.

ORGANIZATION OBJECTIVES:
Enterprise-ready features are designed to help you scale learning for
your entire organization.
We offer an extensive collection of courses on relevant topics that
keep your employees ahead of the curve.

ORGANIZATION MARKET SHARE:

Udemy has market share of 4.27% in learning-management-systems market.


Udemy competes with 247 competitor tools in learning-management-systems
category. The top alternatives for Udemy learning-management-systems tool
are Moodle with 10.51%, LinkedIn Learning with 10.44%, Google Classroom
with 7.72% market share.
Top industries that use Udemy for learning-management-systems are
Technology (262), Software Development (240), Machine Learning (235).
Around the world in 2022, over 8228 companies have started using Udemy as
learning-management-systems tool. Companies using Udemy for learning-
management-systems are majorly from United States with 4005 customers.
44.57% of Udemy customers are from the United States. Other top countries
using Udemy are United Kingdom and Germany with 716(7.97%) and
392(4.36%) customers respectively.

Chapter 2 – TRAINING DETAILS


COURSE OVERVIEW:

This course offers a vast description of Machine Learning adjoining it with


ample knowledge of Python as a base for the same. The course gives indepth
information about how a self learning system which learns and grows with time
and data analysis, and how it is an essential tool of the automated future we
have.

COURSE DETAILS:

This course includes various topics for Machine Learning in accordance to


Python:

 Getting started with python programming


 Data Pre-processing in Python
 Regression in python (Simple Linear, Multiple Linear & Polynomial
Regression)
 Regression Model Selection and Logistic Regression
 Support Vector Machine
 Naïve Bayes
 Classifications (Decision Tree and Random Forest)
 Eclat
 Deep Learning
 Artificial Neuron Networks
 K-Model
 Model Selection
 Create awesome text patterns
 Level up your python programming skill with over 100 best python
practices
COURSE ASSIGNMENT COMPLETION DETAILS

Week 1:

 Making of Regression models


 Selection of Regression model according to the agenda of the project

Week 2:

 K- Nearest Neighbours
 Different types of classifications

Week 3:

 Clustering and its Types


 Deep Learning and various Neural Networks

Week 4:

 Thompson Sampling worksheets


 Model Selection and Boosting
ABSTRACT

The game TIC TAC TOE had an early variant which began in the first century
in the Roman Empire. During that time, it was called Terni Lapilli where the
players only had three pieces and had to move around the empty spaces to play.
The actual game of TIC TAC TOE could be traced back to ancient Egypt. The
game was also known during that time as "Three Men's Morris". The first
reference to Noughts and crosses was made in 1864 in a British novel called
Can You Forgive Her. For many years the game was referred to as noughts and
crosses but was changed in the 20th century by the United States to TIC TAC
TOE. The purpose of this documentation 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.

Chapter 3 – SYSTEM STUDY


3.1 PROBLEM STATEMENT

Program a two-person game of Tic -Tac- Toe. The game is played on a three by
three board. Each player has a marker. One player has an ‘X’, the other an ‘O’.
Players alternate turns to place their marker on the board. The first player to get
three in a row either diagonally, horizontally, or vertically, wins the games. In
the event all squares are taken on the board without a winner then it is a tie. The
program should set up the game by asking for the names of the players. Player
one should be assigned an ‘X’ as their marker, player two should be assigned
the ‘O’. After the game has been completed, the program should congratulate
the winner by name. The players should then have the option to play again. If
they decide to play again, then the program should keep track of the number of
times each player has won and display that information at the end of each game.
You may not assume that any input the user provides you is initially valid.
If the information provided by the user at any stage of the program is invalid,
the program should re-prompt until valid information is provided.

Design Requirements Submit a design document following the design template


outlined in Lab 2. You must include Understanding the Problem (10 pts),
Devising a Plan (20 pts), and a Testing Table (20 pts).
Failure to include any portion of the design will result in point deduction.
Understanding the Problem should outline all of your assumptions, questions,
and understanding of your task. Devising the Plan should include a varying
combination of flow charts and pseudocode. If any code is included in the
Devising the Plan portion a 10 point penalty will be assessed. The Devising a
Plan portion should be detailed enough that it could be given to any developer
to be implemented in any language. Testing should be represented in a test
table. This table may be broken into function specific tests and program specific
tests if you so choose. As you are turning the design document in with your
coded assignment, the Testing Table should be complete with actual values and
comments on why tests may have initially failed. 

3.2 PROJECT OBJECTIVES


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

3.3 PROJECT SCOPE

Scope of Our Game This Report describes all the requirements for the project.
The purpose of this research is to provide a virtual image for the combination of
both structured and unstructured information of my project “Tic Tac Toe”. This
is a single-player strategy game on the Windows platform.

3.4 NEED OF THE SYSTEM

The system is designed in such a way that the data is split into parts, one is used
for training and the other for testing the model, with this we can actually have
the system learn and adapt by analysing the pre-existing data and display the
comprehension of the counterpart. This system can have an application to the
modern world, as safety is a priority for everyone and this model can keep
learning as it grows. The modern world is more vulnerable to unpredicatable
and unforseen outcomes, where this model can come into application the more
its data prone.

INTRODUCTION
2.1 OBJECTIVE:
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, player (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:

 The player with symbol 'o' goes first

 Players alternate placing X s and O s on the board until either

 one player has three in a row, horizontally, vertically or diagonally.

 all nine squares are filled.

 The player who can draw three X s or three O s in a row wins.

 If all nine squares are filled and none of the players have three in a row,
the game is a draw.

SYSTEM DESIGN
INTRODUCTION:

Analysis can be defined by breaking up of any whole so as to find out their


nature, working functionalities etc. It defines design as ary sketches of; to
sketch a pattern or outline for planning. To plan and carry out especially by
artistic arrangement or in a skilful wall. System analysis and design can be
characterized as a set of techniques and processes, a community of interests,
alture and intellectual orientation.
The various tasks in system analysis phase including the following:

 Understanding Application
 Project Planning
 Project Scheduling
 Performing Trade Studies
 Performing Cost Benefit Analysis
 Recommending Alternative Solutions
 Supervising, Installing, Maintaining the system

This system allows the user to feel the taste of playing the game endlessly. First
design the class which will keeps track various functions like board structure,
pixel selection, grid selection, canvas structure, click recognition, gameplay,
game over screen etc. And according to the moves played by the players this
project will display the result in very attractive format

EXISTING SYSTEM:

The Existing system is a simple game to play with paper and pencil between
two people. Here the whole process in square grids, placing X's and O's and
checking for the will repeat every time. So, it will be a tedious job to draw a
nine square grid every time with paper and pencil. The as the records are
maintained in the correct feed on input into the respective field. Suppose the
wrong inputs are entered, then the whole process is to be done again. So, the
users find it difficult to use.

PROPOSED SYSTEM:

To overcome the drawbacks of the existing system, the proposed system has
been evolved. This project aims to reduce the paper work and saving time to
generate accurate results from the player's perspective. The system provides
with the best Graphical User Interface. The efficient reports can be generated by
using this proposed system.

ADVANTAGES OF PROPOSED SYSTEM:

 The game has been made user friendly with proper use of graphical
Interface.
 The user can play as many games without any interpretation
 It is highly reliable, approximate result from user.
 The game has been made as a thorough expert system
 The players can win the game, draw the game or will lose the
game.
 It is a good brain exercise for all age group people.

TECHNICAL FEASIBILITY:

The technical requirement for the system is economic and it doesn't use any
other hardware or software. Technical evaluation must also assess whether he
Existing System can be upgraded to use the new technology and whether the
organization has the expertise to use it. Install all the upgrades cameworks into
the Python IDLE package supported Linux based application. This application
mostly depends two packages namely tkinter package and pygame package
provided by Python 3.6.0.
OPERATIONAL FEASIBILITY:

The system working is quite easy to use and learn due to its simple butattractive
interface. User requires no prerequisites for operating the product. technical
performance includes issues such as determining whether the system can sense
the proper click of the mouse or after sensing the click it places the symbol in
the desired cell and whether the system is organized in such a way that it always
displays the correct result according to the moves made by the players.
SYSTEM REQUIREMENTS

HARDWARE REQUIREMENT(minimum requirement):

Minimum RAM: - 1GB


Minimum Hard Disk: - 128GB
Processor: - Intel Pentium 4(1.50 GHz) or above

SOFTWARE REQUIREMENT(minimum requirement):

Operating System: - Support for both LINUX and WINDOWS users


Back End: - Python 3.10.5 Interpreter
Front End Language: - Python3
SOFTWARE DESCRIPTION

PYTHON 3.10.5 IDLE 2022

DLE stands for Integrated Development and Learning Environment is an


integrated environment for python. It implementation of he language since
1.5.2b. 1. It is packaged as an optional part of the python packaging with many
Linux distribution. It is completely written in python3 and Tkinter GUI toolkit.
IDLE is intended to be a simple IDE and suitable for beginners as well as
advanced users. To that end it is cross platform and avoids feature clutter. The
features provided by the IDLE
includes :

 Python shell with syntax highlighting.

 Integrated debugger with stepping, persistent breakpoints and


call stack visibility
 Multi-window text editor with syntax highlighting, auto
completion, smart indenting etc.

DEVELOPMENT TOOLS AND TECHNOLOGIES

Python is a general purpose interpreted, interactive, object-oriented, and high-


level programming language. It was created by Guido Van Rossum during
1985-1990. ke Perl, Python source code is also available under the GNU
General Public icense (GPL). Python is named after a TV show called "Monty
Python's Flying Circus" Python 3.0(also called "Python 3000" or "Py3k") was
released in December 3, 2008. The latest version of python accumulated new
and redundant ways to program the same task, Python 3.6 had an emphasis on
rem constructs and modules, in keeping with "There should be one and
preferable only one – obvious way to do it". Python's dynamic typing encourage
the programmer to write a code hat is clear, well structured as well as easy to
understand. The features of dynamic typing are:
 Types are bound to values but not to variables.
 Function and method lookup is done at runtime.
 Values are inspect-able .
 There is an interactive interpreter, more than one, in fact.
 You can list the methods supported by any given object.

Because code is automatically compiled to byte code and executed, Python is


suitable for use as a scripting language, Web application implementation
language etc. Because of its strong structuring constructs (nested code blocks,
functions, classes, modules and packages) and its consistent use of objects and
OOP, Python enables you to write clear and logical code for small and large
projects.

GUI (GRAPHICAL USER INTERFACE):

Our goal in this article is to provide you with an introductory of GUI


programming. Inorder to learn the GUI programming, you must first understand
a few core aspects of GUI. So let's begin the discussion. The primary GUI
toolkit will be using TK, Python's default GUI. We'll access Tk from its python
interface called Tkinter. It is not the latest and greatest nor doe the most robust
set of GUI building blocks, but it fairly simple to use and using it, you can
build GUI's that run on most platforms Setting up GUI application is similar to
how an artist produces a painting. Convention there is a single canvas on the
artist must put all the work. In GUI programming a toplevel root windowing
object contains all of the little windowing objects that will be a part of your GUI
application. These can be text labels, buttons, boxes etc. These individual little
GUI comp known as widgets. Top level windows are those that show up stand
alone as part of your application. Interestingly, you can have more than one top
level window for your GUI, but only one of them should be your root window.
The top level window can be created using this: import tkinter top=tkinter . Tk (
) The object returned by tkinter . Tk ( ) is usually referred to as the root window.
Within this window you can place multiple component pieces together to form
your GUI. TK has three geometry managers that help with positioning your
widget set.

 Placer: You provide the size of the widgets and locations to


place them, this manager then places them for you
 Packer: It packs widgets into the correct places
 Grid: It is used to specify GU placement based on grid
coordinates.

Now once the packer has determined the sizes and alignments of your widgets,
it willhen place them on the screen for you. When all the widgets are in place
we instruct he application to infinite main loop. In Tkinter the code that does it
is Tkinter . mainloop ( ) his is normally the last piece of sequential code your
program runs.
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.

OVERVIEW OF THE PROJECT:

This project is divided into several modules and all the modules are appearing
in one class. These modules are called from the main module located at the root
of the project. All the modules have different as well as vital functionalities in
order to develop the right product. These modules are designed in such a way
that they reflect a highly cohesiveness.

MODULE DESCRIPTION:

INITIALIZATION:

In the main class we've created a constructor which will hold all the tkinter
widgets that we are using in get called canvas to draw graphs and plots on our
root window. We set the background colour as white. Now we want to realize
the effects that we are made in our root window. For that we have to use the
pack actually used to interact the GUI widget with our computer program. In the
bind function we've passed two objects namely '< x >' ,l to exit from the root
window. In the root window there top level. The minimize button (- ), the
maximize whenever the user clicks on the X button the bind function should
care that and accordingly the root window will destroy that means it could not
be displayed any more. Then we set our game state to zero ( 0 ) and call the title
screen module. After that we create list with nine strings and initiate each of
them with a value zero ( 0 ) and store it in a variable called board.

TITLE SCREEN:

In this module, what we've done is we use the delete method to clear the canvas.
We use he special tag "all" to delete all the items on the canvas. Then we create
three rectangles on our root window. We create these rectangles by using
canvas supported standard item call create_rectangle. For drawing the first
rectangle we've passed the rectangle bounding size which is nothing but the
original window size and the rectangle options which includes fill boundary
colour and outline as an object. We choose Applying the same procedure, we
have created the second rectangle. The only additional thing that is done here is
regardless of sending the original window size we'll send the the X and Y axis is
such a adjusted window size as an rectangle we've applied way that the beauty
of the window is prese the same procedure and we select appropriate colour for
displaying all the texts that will be appeared in this rectangle. Now we he and
besides that, because we also would like to increase the usability of the software
that we are developing so we also have to create another text that will increase
the usability of the software. For that we are using canvas supported standard
item called create_text that will enable us to create informative text on the
screen. Intuitively, the title of the game should be TIC TAC TOE and just
below to that another text that will be appearing is Click to play.

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. So, to do that first we
clear all the widgets that is appearing al parameter "all" to it. Then In the
window by using the delete method we reset the board by assigning 0 value to
all the nine locations in the board. Now we've to draw two lines vertically and
horizontally. To achieve this, we have to use canvas supported should have to
another standard item called create_line To use the pass the line co-ordinates
and the line options as a parameter. Thus, we create a loop which will repeat
two times and inside the loop we declare two create_line functions with
appropriate X co-ordinates, Y co-ordinates, grid / line width and grid colour.
Insides the loop we use the create_line function twice because one is for
drawing the lines vertically and the other one does the desired job for us by
creating the lines horizontally By this we've completed our board structure.

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.
If the outcome is in favour of player 1, "O Wins" appears on the screen in the
form of a text. Similarly, if the outcome is In favour of player2, "X Wins"
should appear on the screen and if the outcome is a draw then both the players
will see the text "Draw" on the screen. We add one extra feature in the game
over module by introducing a text called "Click to play again" and we're very
optimistic that it should increase the usability of the developed software. For
displaying the texts, we've used the canvas supported standard item call
create_text function. In the game over screen firstly we create a rectangle on
the canvas and fills it with appropriate colour and inside that rectangle all the
texts will appear. We've created the texts by adjusting the text size, font style,
text height, text width and text colour .

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. It
waits for an event to happen. Events are generally key pressed or mouse
operations by the users. We've already set the game states globally by assigning
the values STATE_TITLE_SCREEN to 0, STATE_X_TURN to 1,
STATE_O_TURN to 2 and STATE_GAME_OVER to 3. In the click method
we've passed the first argument implicitly (called 'self ) which is the reference to
our main class itself and it should have the 'event object that merely describes
what is actually happened. We begin our task by converting the pixels into gird
coordinates and then we have to check for the current he will continue. Now if
game state is 0, thirteen and sets the game states as the value of the first player.
If the game state is 1 turn and the cell is empty then the control goes to new
move modo mandatorily pass the current player and the board coordinates as
arguments) and the appropriate cell is filled up with symbol X. Now it checks
all the possible conditions (i.e. whether player X has won or it is a draw) one by
one. So, at first the control moves to has won module and if the result is true
then it sets the game state to 3 and calls the game over module by passing the
parameter "X wins'. If it is false then the control goes to is a draw module and if
the result is true then again it will set the game state to 3 and calls the game over
module with the parameter Draw'. If the result of both the cases is false then
only it will set the game state as 2 which is nothing but player O can now take
its turn. Now If the game state is 2 i.e. O's turn and the cell is empty then the
control goes to new move module and the appropriate cell is filled up with
symbol O.

Now, it checks all the possible conditions (i.e. whether player O has won or its a
draw) one by one. So, at first the control moves to has won module and if the
result is true then it sets the game state to 3 and calls the game over module by
passing the parameter 'O wins'. If it is false the result is true then again it will
set the game state to 3 and calls the game over module with the parameter
'Draw'. If the result of both the cases is false then only it will set the game state
as I which is nothing but player 1 can now turn. Finally, it checks for if the
game state is being at 3 or not. If it is 3, then it will reset the board by calling
the module new board and sets the game state according to the first player. With
this we're completing most of the work that is behind our game logic

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 and the grid coordinates from the click
module as an argument and places the symbol of the player in the desired cell.
Now let us consider our board structure:
Here X and Y are 0 based grid coordinates. If the current player is X then it will
call the draw X module (discussed later) with the grid coordinates and places
the X symbol with appropriate size and colour into that grid. Now if the current
player is O then it will call the draw O module with the 0 based grid coordinates
and places the O symbol into that cell.

DRAW X:

This module deals with drawing X on the canvas. So, for that what we've to do
is, first of all we've to convert the grid into pixels and then we can start our
drawing using canvas supported standard packages namely create_line. For that
reason, we've called the grid_to_pixel module twice and we get the converted
pixels. Now we must have to adjust.

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. Now the has_won function
takes those pixels as he checking for the winner is quite simple. If any of the
players can able to fill all the cells in a row vertically or horizontally or
diagonally, he /she will consider to be the clear winner. So, in the first for
basically check that whether or horizontally or diagonally) are filled with the
same symbol or not. Now if this condition satisfies, then the player with that
symbol is the winner. In the second for loop we need to check those winning
position. So, we need to check the positions ([][0],[0][1],[0][2]) or ([1][01.[1]
[1],[1][21) or ([2110],[2][1].[2][21) or ([][].[1][01,[2][0]) or ([][ 1].[1][1],[2][1])
or ([][2].[1][2],[2][2]) or ([OJO].[1 1[1],[2][2]) or ([][2].[1][1],[2][0]) and by
checking these positions we will certainly get the winner.

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. All we've to do is check whether all the board boxes are filled.
We can do this by iterating through the board array

GRID TO PIXELS:

The main objective of this module is to transform the grid coordinate into
pixels. Intuitively we've passed the grid coordinate as an argument and this
module returns accurate pixel coordinate of the centre. The pixel coordinate
should be calculated with the help of grid coordinate and the cell size. Thus, we
add the original cell size with the half of it and multiplied it with the gird
coordinate and stored the result in a variable called pixel_coord. By doing this,
the grid to pixel transformation is mostly done.

PIXELS TO GRID:

It is just the reverse of the previous module. This module performs exactlythe
opposite task, taking a pixel coordinate at and converting this into its equivalent
grid coordinate. Somehow the canvas has a few extra pixels on the right and
bottom side so we've to fix this. For clipping the extra pixels, we must check the
condition that if the pixel coordinate is somehow greater than the original
window size then we've to reduce the window size. The transformation can be
achieved by dividing the pixel coordinates by the cell size. The resultant grid
can now be stored into a variable say grid_coord.

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. We want the access from the current instance in our exit () method
which is done through self. self . destroy () However, this only destroys the
frame and its child windows, like the canvas, not the top-level window.

USE CASE DIAGRAM


A use case diagram is used to represent the dynamic behavior of a system. It
encapsulates the system's functionality by incorporating use cases, actors, and
their relationships. It models the tasks, services, and functions required by a
system/subsystem of an application. It depicts the high-level functionality of a
system and also tells how the user handles a system. The main purpose of a use
case diagram is to portray the dynamic aspect of a system. It accumulates the
system's requirement, which includes both internal as well as external
influences. It invokes persons, use cases, and several things that invoke the
actors and elements accountable for the implementation of use case diagrams. It
represents how an entity from the external environment can interact with a part
of the system.
It is essential to analyze the whole system before starting with drawing a use
case diagram, and then the system's functionalities are found. And once every
single functionality is identified, they are then transformed into the use cases to
be used in the use case diagram.
After that, we will enlist the actors that will interact with the system. The actors
are the person or a thing that invokes the functionality of a system. It may be a
system or a private entity, such that it requires an entity to be pertinent to the
functionalities of the system to which it is going to interact.
Once both the actors and use cases are enlisted, the relation between the actor
and use case/ system is inspected. It identifies the no of times an actor
communicates with the system. Basically, an actor can interact multiple times
with a use case or system at a particular instance of time.

USE CASE DIAGRAM:


SYSTEM FLOW DIAGRAM

input is coming to the system and output going out of the system. With the help
of the diagram, it is possible to control the event decisions of the system and
how data is flowing to the system. Therefore, the system flow diagram is
basically a visual representation of data flow, excluding the minor parts and
including the major parts of the system in a sequential manner.
It is just like a data flow diagram that includes all the major steps of the flow of
data in a system in a systematic and sequential manner and it is required
because of its varieties of uses.
DATA FLOW DIAGRAM

DFD graphically representing the functions, or processes, which capture,


manipulate, store, and distribute data between a system and its environment
and between components of a system. The visual representation makes it a
good communication tool between User and System designer. Structure of
DFD allows starting from a broad overview and expand it to a hierarchy of
detailed diagrams. DFD has often been used due to the following reasons:
 Logical information flow of the system
 Determination of physical system construction requirements
 Simplicity of notation
 Establishment of manual and automated systems requirements
INPUT DESIGN:

Input design is part of overall system design that requires special attention
designing input data is to make the data entered easy and free from errors. The
input forms are designed using the controls available in PYTHON
INTERPRETER. Validation is made for each and every event that is
happened. Help (how to play the game) information is provided for the users
during when the players feels difficult. Input design is the process of converting
the user originated inputs to a computer-based format. A system user interacting
through a workstation must be able to tell the system whether to accept the input
to produce reports. The collection of input data is considered to be most
expensive part of the system design. Since the input has to be planned in such a
manner so as to get relevant information, extreme care is taken to obtain
pertinent information.

OUTPUT DESIGN:

Output design this application "TIC TAC TOE" generally refers to the results
and information that are generated by the system for many end-users; output is
the main reason for developing the system and the basis on which they evaluate
the usefulness of the application. The output is designed in such a way that it is
attractive, convenient and informative. Board is designed with various features,
which make the console output more pleasing. As the outputs are the most
important sources of information to the users, better design should improve the
system's relationships with us and also will help in decision making. Form
design elaborates the way output is presented and the layout available for
capturing information. one of the most important factors of the system is the
output it produces. This system refers to the results and information generated.
Basically, the output from a computer system is used to communicate the result
of processing to the user.
SYSTEM TESTING

INTRODUCTION:

Once source code has been generated, software must be tested to uncover and
correct as many errors as possible before delivery to customer. Our goal is to
design a series of test cases that have a high likelihood of finding errors. To
uncover the residual errors software Techniques are used. These tec systematic
guidance for designing test that Exercise the internal logic of software
components, and Exercise the input and output domains of the program to
uncover errors in program function, behaviour and performance.

STEPS:

Software is tested from two different perspectives: Internal program logic is


exercised using -White box test case design techniques. Software requirements
are exercised using -block box test case design techniques In both cases, the
intent is to find the maximum number of errors with the minimum amount of
effort and time and cost

TESTING METHODOLOGIES:

A strategy for software testing mutests that are necessary to verify that a small
source code segment has been correctly implemented as well as high-level tests
that validate major system functions against customer requirements. A strategy
must provide guidance for the practitioner and a set of milestones for the
manager. Because the steps of the test strategy occur at a time when deadline
pressure begins to rise, progress must be measurable and problems must surface
as early as possible. Following testing techniques are well known and the same
strategy is adopted during this project testing.

UNIT TESTING:

Since this is a game which may have various forms of user input, it would be
nearly Impossible to test every possible user, testing functionality and likely
user scenarios should be our overall goal of testing Tic-Tac-Toe. Unit Testing
focuses verification effort on the smallest unit of software design- the software
component or module. The unit test is white-box oriented. The unit testing is
implemented in every module of this project by giving correct manual input to
the system, the inputted data are stored in database and can be retrieved. If you
want required module to access input or get the output from the End user, any
error will accrue that time will provide handler to show what type of error will
accrued.

INTEGRATION TESTING:

First and most importantly we will ensure the tkinter builds and runs without
errors. Also make sure it still works while embedded. GUI should display
correctly on the root window. There should be no states which freeze the game.
Switching between the players should update seamlessly and no logical errors
should occur. All warnings (highlights) should be identified by the game state
and displayed correctly by the GUI. All in all, a full game should be playable
without programming or logical errors.

SYSTEM TESTING:

System testing is actually a series of different tests whose primary purpose is to


fully exercise the computer-based system. Below we have described the two
types of testing which have been taken for this project. it is to check all modules
worked on input basis. If you want change an values or inputs, it will change all
information, so specified input is must. System testing can be stated as the
process of validating and verifying hat a computer program / application /
product:
 Meets the requirements that guided its design and development
 Works as expected
 Can be implemented with the same characteristics
 satisfies the needs of stakeholders.

PERFORMANCE TESTING:

Performance testing is designed to test the run-time performance of the software


within the context of an integrated system. Performance testing occurs
throughout all steps in the testing process. Even at the unit level, the
performance of an individual module may be assessed as white-box tests are
conducted.
SYSTEM IMPLEMENTATION

PURPOSE:

System implementation is the important stage of project when the theoretical


design is tuned into practical system. The main stages in the implementation are
as follows-
 Planning
 Training
 System testing and
 Changeover Planning
Planning is the first task in the system implementation. At the time of
implementation of any system people from different departments and system
analysts involve. They are confirmed to practical problem of controlling various
activities of people outside their own data processing departments.

SYSTEM MAINTENANCE:

Software maintenance is far more than finding mistakes. Provision must be


made for environment changes, which may affect either the computer, or other
parts of the computer-based systems. Such activity is normally called
maintenance. It includes both the improvement of the system functions a faults,
which arise during the operation of a new system. It may ement of a large
proportion of computer department recourses. The main task may be to adapt
existing systems in a changing environment. Back up for the entire and stored in
storage devices like flash drives, pen drive to restore the system at the earliest.
If there is a breakdown or collapse, then the system gives provision to restore
from database files. We focus on four types of maintenance:

 Adaptive Maintenance
 Perfective Maintenance
 Corrective Maintenance
 Preventive Maintenance

CONCLUSION AND FUTURE ENCHANCEMENTS

ALLOW THE PLAYERS TO CHOOSE THE MODE OF THE GAME:

An option to select the mode of the game that is whether the player wants to
play the game with his/her friends or with the machine.

ALLOW THE PLAYERS TO DEFINE THE METRICS:

An option to increase the board to size to n x n, where n can be any positive


number (20). This will increase the complexity of the code and when added
with artificial intelligence will greatly make the game robust. Also, we can add
a feature where k(< n) consecutive marks/dots (filled by the user) is a
point/score. Or we can go even further and use a range of number n.

INTRODUCTION OF ARTIFICIAL INTELLIGENCE:


An option of playing against the computer (machine) can be added too. An
algorithm can be implemented for the machine based on actual rules a player
uses to fill the Tic-Tac-Toe board. This can pose a challenge to the user when
playing.

INTRODUCTION OF DIFFICULTY LEVELS:


One option to select the difficulty levels of the game can be added. We
would also like to create a computer AI that offered increasing resistance as
the difficulty level increased.

USER PROFILES AND SCORES:


One of the other enhancements could be that users can create their profiles
and save their scores.

IN-GAME ASSISTANT:
An option to include an Assistant which will provide hints and suggestions
to the user when playing against a bot.

Chapter 5 – SOFTWARE CODING AND IMPLEMENTATION

5.1 INTRODUCTION

5.1.1 System coding Environment and Standards Followed

Python is a popular programming language. It was created by Guido van


Rossum, and released in 1991.
It is used for:
 Machine Learning Projects
 software development,
 mathematics,
 system scripting.
Python can be used on a server to create web applications. It can be used
alongside software to create workflows and can connect to database systems. It
can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software
development. It works on different platforms (Windows, Mac, Linux, Raspberry
Pi)

This software has a simple syntax similar to the English language. It has syntax
that allows developers to write programs with fewer lines than some other
programming languages. Python runs on an interpreter system, meaning that
code can be executed as soon as it is written. This means that prototyping can be
very quick. It can be treated in a procedural way, an object-oriented way or a
functional way.
Machine Learning Synopsis:

 Machine learning involves a computer to be trained using a given


data set, and use this training to predict the properties of a given
new data. For example, we can train a computer by feeding it
1000 images of cats and 1000 more images which are not of a cat,
and tell each time to the computer whether a picture is cat or not.
Then if we show the computer a new image, then from the above
training, the computer should be able to tell whether this new
image is a cat or not.

 Machine learning is a type of artificial intelligence (AI) that


provides computers with the ability to learn without being
explicitly programmed. Machine learning focuses on the
development of Computer Programs that can change when
exposed to new
5.2.2 Sample Code Layouts

 Firstly, we will import pygame, sys, and NumPy python


libraries are used to build this game.
 Set the width and height of the game window. Also, set
the background color as BG_COLOR = (20, 200, 160)
 Set the LINE_COLOR, CIRCLE_COLOR, and
CROSS_COLOR according to your choice.
 To create a board we will use np.zeros().
 pygame.draw.line() is used for drawing
a horizontal line and vertical line.

import pygame,
sys import numpy as
np pygame.init()
WIDTH = 600
HEIGHT = 600
LINE_WIDTH = 15
WIN_LINE_WIDTH = 15
BOARD_ROWS = 3
BOARD_COLS = 3 S
QUARE_SIZE = 200
CIRCLE_RADIUS = 60
CIRCLE_WIDTH = 15
CROSS_WIDTH = 25
SPACE = 55
BG_COLOR = (20, 200, 160)
LINE_COLOR = (23, 145, 135)
CIRCLE_COLOR = (239, 231, 200)
CROSS_COLOR = (66, 66, 66)
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption( 'TIC TAC TOE' )
screen.fill( BG_COLOR )
board = np.zeros( (BOARD_ROWS, BOARD_COLS) )
def draw_lines():
pygame.draw.line( screen, LINE_COLOR, (0, SQUARE_SIZE), (WIDTH,
SQUARE_SIZE), LINE_WIDTH )
pygame.draw.line( screen, LINE_COLOR, (0, 2 * SQUARE_SIZE), (WIDTH, 2
* SQUARE_SIZE), LINE_WIDTH )
pygame.draw.line( screen, LINE_COLOR, (SQUARE_SIZE, 0),
(SQUARE_SIZE, HEIGHT), LINE_WIDTH )
pygame.draw.line( screen, LINE_COLOR, (2 * SQUARE_SIZE, 0), (2 *
SQUARE_SIZE, HEIGHT), LINE_WIDTH )
 def draw_figures() is used for drawing the circle and
line for the cross.
 def mark_square() function is used for marking on the
board and it will have 3 parameters.
 def available_square() will return true if the square is
available and it’s going to return false if not available.
 def is_board_full() function will return true if the board
is full and if it’s not full then it will return false. And it
will loop through rows and columns.
 if board[row][col] == 0 that means we have found the
empty square and it will return false and if we don’t find
the empty square then it will return true.

def draw_figures():
for row in range(BOARD_ROWS):
for col in range(BOARD_COLS):
if board[row][col] == 1:
pygame.draw.circle( screen, CIRCLE_COLOR, (int( col * SQUARE_SIZE +
SQUARE_SIZE//2 ), int( row * SQUARE_SIZE + SQUARE_SIZE//2 )),
CIRCLE_RADIUS, CIRCLE_WIDTH )
elif board[row][col] == 2:
pygame.draw.line( screen, CROSS_COLOR, (col * SQUARE_SIZE + SPACE,
row * SQUARE_SIZE + SQUARE_SIZE - SPACE), (col * SQUARE_SIZE +
SQUARE_SIZE - SPACE, row * SQUARE_SIZE + SPACE), CROSS_WIDTH )
pygame.draw.line( screen, CROSS_COLOR, (col * SQUARE_SIZE + SPACE,
row * SQUARE_SIZE + SPACE), (col * SQUARE_SIZE + SQUARE_SIZE -
SPACE, row * SQUARE_SIZE + SQUARE_SIZE - SPACE), CROSS_WIDTH )
def mark_square(row, col, player):
board[row][col] = player
def available_square(row, col):
return board[row][col] == 0
def is_board_full():
for row in range(BOARD_ROWS):
for col in range(BOARD_COLS):
if board[row][col] == 0:
return False
return True
APPLICATION SCREEN SHOTS

In the below output, you can see that “X” wins the game.
In the below output, you can see that “o” wins the game.

In the below output, you can see that “no one” wins the game.
LEARNING AND ACHIEVEMENT
The project helped me understand how the automated world can actually
be brought to light with help of these self learning technologies, I learnt a
lot of essential information about data analysis as well which is the base
for Artificial Intelligence. It taught me patience as well, because the
project was not as error free as it looked above but I learnt to self rectify
these issues. I also learnt programming in Python and how it can be
collaborated, also why it is one of the most used computer languages.

It was a great way to learn how to program in python and it exposed the
students to a lot of things that can be done with machine learning and all
its applications in the present day.

BIBLIOGRAPHY
https://www.kaggle.com/c/titanic

https://www.tutorialspoint.com/python/

https://stackoverflow.com/

https://www.geeksforgeeks.org/

https://www.Youtube.com/

You might also like