0% found this document useful (0 votes)
43 views

Report Final

This document describes a mini project report on a Tic Tac Toe game created in Python. It includes a 3x3 grid to represent the game board, functions to display the board, check for a winner, and validate player input. The main game loop allows two players to take turns marking spaces with 'X' or 'O' until there is a winner or a tie when the board is full. Output examples show the board being printed when 'X' or 'O' wins as well as when the game results in a tie.

Uploaded by

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

Report Final

This document describes a mini project report on a Tic Tac Toe game created in Python. It includes a 3x3 grid to represent the game board, functions to display the board, check for a winner, and validate player input. The main game loop allows two players to take turns marking spaces with 'X' or 'O' until there is a winner or a tie when the board is full. Output examples show the board being printed when 'X' or 'O' wins as well as when the game results in a tie.

Uploaded by

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

VISVESVARAYA TECHNOLOGICAL UNIVERSITY,

BELAGAVI, KARNATAKA, INDIA

An Autonomous Institution with A' Grade UGC by NAAC UGC, Approved by UGC, AICTE,
Government of Karnataka, Yelahanka ,Bengaluru-560064, Karnataka, India.

Report On
‘TIC TAC TOE’

A mini project report submitted in partial fulfillments of a requirement for the.


. first year of

BACHELOR OF ENGINEERING
In

ELECTRONICS AND COMMUNICATION ENGINEERING


2023-2024
Submitted By
Team members: D JAYANTH-1NT23EC023-T
U SAI SWAROOP-1NT23EC041-T
NIHALDEEP PRADHAN -
1NT23EC048-T
SOUNAK PRATIHAR -
1NT23EC031-T

Under the Guidance of

D.r Harsha Karamchandani


Asst, Professor
Dept. of Electronics and Communication Engineering.
. Nitte Meenakshi Institute of Technology
Footer 1
Yelahanka. Bangalore-560064

An Autonomous Institution with A' Grade UGC by NAAC UGC, Approved by UGC, AICTE,
Government of Karnataka, Yelahanka ,Bengaluru-560064, Karnataka, India.

Department of Electronics and Communication Engineering

Certificate
This is to certify that D JAYANTH(1NT23EC023-T),U SAI
SWAROOP(1NT23EC041-T),NIHALDEEP PRADHAN(1NT23EC048-T),
SOUNAK PRATIHAR(1NT23EC031-T ) has submitted mini project report
entitled“TIC TAC TOE ”fulfilment of First year of Bachelor of Engineering in
Electronics and Communication Engineering from Visvesvaraya Technological
University, Belagavi during the year 2023- 2024.It si certified that al the
corrections and suggestions indicated for internal assessment have been
incorporated in the report. The report has been approved as it satisfies the
academic requirements in respect of work prescribed for the aforesaid degree.

Dr.Harsha Karamchandani D.r Ramachandra AC D.r H.Nagaraj

Guide HOD Principal

Footer 2
Acknowledgement
It is my privilege and duty to acknowledge this kind of help and guidance
received from several people in the preparation of this report. It would not
have been possible to prepare this report in this form without valuable
suggestions, cooperation and guidance.

I wish to record my sincere gratitude to Management, and Dr. H.C. Nagaraj,


Principal, Nitte Meenakshi Institute of Technology, Bengaluru for the
permission provided to accomplish this project.

My sincere thanks to Dr. Ramachandra. A C, Professor and Head,


Department of Electronics and Communication Engineering for his valuable
suggestions and guidance.

My sincere gratitude to Dr. Rajesh N, Dr. Sunil S. Harakannanavar and Dr.


Thimmaraja Yadava G, Coordinators, Department of Electronics and
Communication Engineering, for their valuable suggestions in preparing this
report.

Me and my team express my sincere gratitude to our beloved guide,


Dr.Harsha Karamchandani, Assistant professor, Department of Electronics
and Communication and Engineering for his/her support and guidance.

I am extremely great full of faculty members of Department of Electronics


and Communication Engineering, and friends for their support and
encouragement in successful completion of this project.

Team members: D JAYANTH-1NT23EC023-T


U SAI SWAROOP-1NT23EC041-T
NIHALDEEP -1NT23EC048-T
SAUNAK PRATIHAR -
1NT23EC031-T

Footer 3
Contents
Table 1
Topic Page number

Introduction 5-6

Working code 8-11

Output 12-16

Conclusion 17

Footer 4
INTRODUCTION
A Tic Tac Toe game in Python is a program that
emulates the classic two-player board game. It provides a
platform for players to take turns, marking spaces on a 3x3
grid, with the goal of aligning three of their marks (either
'X' or 'O') horizontally, vertically, or diagonally. The
program prompts users to input their moves, validates the
inputs to ensure they are within the valid range and the
chosen position is unoccupied, and then updates the game
board accordingly. The game continues until there is a
winner or the board is filled, resulting in a tie.

Key components of this Python Tic Tac Toe project


include:

1.Board Representation:

A 3x3 grid representing the Tic Tac Toe board,


initialized with empty spaces.

2.Display Board:

A function to visually display the current state of the


Tic Tac Toe board after each move.

3.Player Input:

Mechanism for two players to take turns and input their


moves. Validation to ensure the input is a valid position
on the board and is not already occupied.

Footer 5
4.Update Board:

Logic to update the board based on the player's move,


marking the chosen space with 'X' or 'O'.

5.Check Winner:

A function to check for a winner after each move,


examining rows, columns, and diagonals for a winning
alignment.

6.Game Loop:

A loop that continues until there is a winner or the board is


filled, allowing players to take turns.

Footer 6
`

TIC TAC TOE

Footer 7
PART- 1 (DEFINING THE TIC TAC TOE BOARD AND TO
CHECK THE WINNER)

The “print_board” function displays the tic tac toe board by


printing each row with elements separated by “|” and horizontal
lines between rows. It provides the visual state of the game

The “check_winner “function examines the tic tac toe board if


there is a winner. It checks for matching symbols in row,
columns. If winner is identified it returns the winner symbol else
it returns “None”
Footer 8
PART-2 (CHECKS FOR DIAGONAL WINNER AND IF BOARD
IS FULL)

This segment of the code checks for the winners in both top-
left-bottom and top-right-bottom diagonals. So basically, it just
checks for the winners in the diagonals.

The “is_board_full” function checks for empty spaces in the


board. If there are any empty spaces it returns False and if the
board is full, it returns True.

Footer 9
PART-3 (THE MAIN GAMEPLAY AND PROMPTS THE USER
FOR A ROW AND COLUMN INPUT)

This segment of code initializes a 3*3 tic tac toe board and sets
“X” as starting player. Then it runs an infinite loop prompting the
user for a row and column input until there is a winner.

Footer 10
PART-4 (PLAYER MOVES AND PRINTING THE WINNER)

This part of code deals with the player moves in game. It checks if the
chosen cell is empty, updates the board, checks for winner or a tie, and
toggles between “X” and “O” for the next turn and also returns which
player has to play next. If the selected cell is already taken it prompts
the user to try again.
The game continues until there is a winner or tie.

Footer 11
OUTPUT FOR (CASE-1)-“X” or “O” Wins

Footer 12
OUTPUT EXPLANATION FOR (CASE-1)

In the play_tic_tac_toe function, a 3x3 tic-tac-toe board is


initialized, and players alternate turns entering 'X' or 'O' in
a chosen row and column. After each move, the program
checks for a winner using the check_winner function. If
there's a winner, it declares the winner and ends the game.
If the board is full with no winner, it declares a tie and
concludes the game

Footer 13
OUTPUT FOR (CASE-2)-“It is a Tie”

Footer 14
v

Footer 15
OUTPUT EXPLANATION FOR (CASE-2)

In the play_tic_tac_toe function, the 3x3 tic-tac-toe board is gradually filled with
'X' and 'O' moves as players take turns. After each move, the program
meticulously examines the rows, columns, and diagonals using the check_winner
function to ascertain if there is a continuous line of three identical symbols.

In the event that the board becomes fully occupied with 'X' and 'O' moves, and yet
no player has succeeded in creating a winning sequence, the program reaches a
crucial juncture. At this point, it carefully inspects the entire board for any
absence of consecutive three identical symbols in any row, column, or diagonal. If
this condition holds true, the program acknowledges the absence of a winner and
gracefully concludes the game by printing the final state of the board. It then
declares, "It's a tie!"—signifying that neither player managed to achieve a winning
combination, resulting in a draw to bring the game to a clo

Footer 16
CONCLUSION:-

In conclusion, our Tic-Tac-Toe mini project seamlessly


integrates fundamental Python programming concepts with
the timeless enjoyment of the game. The code, featuring
key elements such as nested loops, conditional checks, and
user input validation, delivers an engaging and strategic
gaming experience. Overcoming obstacles encountered in
the development process, this project showcases the
harmonious blend of coding ingenuity and recreational
involvement. As the final moves are made on the virtual
board, we express sincere gratitude for your participation
in playing this game. Your involvement not only enhances
the overall enjoyment but also contributes to the
continual refinement of this Python-driven creation. Delve
into the world of Tic-Tac-Toe, and thank you for being an
integral part of this coding journey!

Footer 17
Footer 18
Footer 19
Footer 20
Footer 21

You might also like