Professional Documents
Culture Documents
PWP 1
PWP 1
ON
SUBMITTED BY
PROF. Salunke.N.S
Sanjivani Pratisthan’s
S. P. I. T. POLYTECHNIC, KURUND
2023 – 2024
Sanjivani Pratisthan’s
S. P. I. T. POLYTECHNIC, KURUND
CERTIFICATE
This is to certify that a micro project work entitled
in partial fulfillment for the award of “Diploma in Computer Engineering” during the year
2023-24 as required by the Maharashtra State Board of Technical Education, Mumbai. The micro
project report has been approved as it satisfies the academic requirements in respect of micro
project work prescribed by MSBTE, Mumbai.
I would like to express my sincere thanks to Prof.Salunke.N.S. for his valuable guidance and
support in completing my project.
I would also like to express my gratitude towards our principal Prof. Kapse S. D. for giving me
this great opportunity to do a project on Tic Tac Toe Game Without their support and
suggestions, this project would not have been completed.
Micro Project
ON
"Tic tac toe game "
❖ Rationale
Both the player plays one by one simultaneously. In one move, players need to select
one position in the 3×3 grid and put their mark at that place. The game runs continuously
until one may wins. In the previous article, we have built a simple Tic Tac Toe Game in
Android but in this article, we have the following additional features inside the app .
❖ Proposed methodology
In this project, we create a tic tac toe game using python programming.
❖ Brief Description:-
A two- board player tic-tac-toe game, which we can play on the command line.
Initially, we’ll make a blank game and then we’ll take inputs from the players and
we’ll check for the winning situation if the entire board gets loaded and no one
wins, we’ll declare the result as “Tie” and ask users if they want to restart the
game.
❖ Coding
Utilize the dictionary to make our game board. A dictionary is a primitive data
type in python that kept data in “key: value” format. and thus, we’ll make a
dictionary of length 9 and each key will illustrate a block on the board and its
related value will illustrate the move made by a player. and we’ll make a function
printBoard() that we can utilize every time we want to print the updated board
in the game.
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' ,
'4': ' ' , '5': ' ' , '6': ' ' ,
'1': ' ' , '2': ' ' , '3': ' ' }
def printBoard(board):
print(board['7'] + '|' + board['8'] + '|' + board['9'])
print('-+-+-')
print(board['4'] + '|' + board['5'] + '|' + board['6'])
print('-+-+-')
print(board['1'] + '|' + board['2'] + '|' + board['3'])
Now, in the main function, we’ll first take the input from the player and review if the input
is a valid move or not. If the block that the player requests to move to is valid, we’ll fill
that block else we’ll ask the user to pick another block.
def game():
turn = 'X'
count = 0
for i in range(10):
printBoard(theBoard)
print("It's your turn," + turn + ".Move to which place?")
move = input()
if theBoard[move] == ' ':
theBoard[move] = turn
count += 1
else:
print("That place is already filled.\nMove to which place?")
continue
continue
Now, to inspect the winning condition, we’ll review a total of 8 conditions and whichever
player has made the last move, we’ll declare that player a winner. And if no one wins,
we’ll declare ‘tie’.
# Now we will check if player X or O has won,for every move after 5 moves.
if count >= 5:
if theBoard['7'] == theBoard['8'] == theBoard['9'] != ' ': # across the
top
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['4'] == theBoard['5'] == theBoard['6'] != ' ': # across the
middle
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['1'] == theBoard['2'] == theBoard['3'] != ' ': # across the
bottom
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['1'] == theBoard['4'] == theBoard['7'] != ' ': # down the
left side
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['2'] == theBoard['5'] == theBoard['8'] != ' ': # down the
middle
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['3'] == theBoard['6'] == theBoard['9'] != ' ': # down the
right side
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['7'] == theBoard['5'] == theBoard['3'] != ' ': # diagonal
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
elif theBoard['1'] == theBoard['5'] == theBoard['9'] != ' ': # diagonal
printBoard(theBoard)
print("\nGame Over.\n")
print(" **** " +turn + " won. ****")
break
# If neither X nor O wins and the board is full, we'll declare the result as
'tie'.
if count == 9:
print("\nGame Over.\n")
print("It's a Tie!!")
# we have to change the player after every move.
if turn =='X':
turn = 'O'
else:
turn = 'X'
The tic-tac-toe game is ready to play full python code is given below.
the output of the above python program the game is working and a working screenshot
of this game is given below.
❖ Actual Report:
Introduction:
In this article, we are going to make a tic-tac-toe game that has both online and offline
modes. So for this project, we are going to use Kotlin and XML. Tic-Tac-Toe is a two-
player game. Each player has X or O. Both the player plays one by one simultaneously. In
one move, players need to select one position in the 3×3 grid and put their mark at that
place. The game runs continuously until one may wins. In the previous article, we have
built a simple Tic Tac Toe Game in Android but in this article, we have the following
additional features inside the app:
Step 2: Before going to the coding section first you have to do some pre-task
❖ Conclusion
A two-player tic-tac-toe game, which we can play on the command line.
Python is generally utilized for creating websites and software, task
automation, data analysis, and data visualization.
The game is as easy to code as to play and in this article, since a long time when we used
to have keypad phones