Report Final
Report Final
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’
BACHELOR OF ENGINEERING
In
An Autonomous Institution with A' Grade UGC by NAAC UGC, Approved by UGC, AICTE,
Government of Karnataka, Yelahanka ,Bengaluru-560064, Karnataka, India.
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.
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.
Footer 3
Contents
Table 1
Topic Page number
Introduction 5-6
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.
1.Board Representation:
2.Display Board:
3.Player Input:
Footer 5
4.Update Board:
5.Check Winner:
6.Game Loop:
Footer 6
`
Footer 7
PART- 1 (DEFINING THE TIC TAC TOE BOARD AND TO
CHECK THE WINNER)
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.
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)
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:-
Footer 17
Footer 18
Footer 19
Footer 20
Footer 21