Professional Documents
Culture Documents
PROJECT REPORT
A PROJECT REPORT ON
Game: tic tac toe
Sr NO. Name of Students Seat No. Roll No. Enrollment No.
1|P age
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION, MUMBAI
Certificate
This is to certify that, Purwa Chaudhari, Rajnandeeni Patil ,Chetana
Bedse ,Shambhavi Bedse, Vrushika More of Sixth Semester of Computer
Engineering Diploma Program at (1432) Government Polytechnic
Nandurbar, has completed the satisfactorily in Subject PWP(22616 ) in the
academic year 2023 - 2024 as prescribed in the MSBTE curriculum of I
Scheme.
Place: Nandurbar
Date: 02/04/2024
Enrolment No:
1) 2114320035
2) 2114320053
3) 2114320075
4) 2114320041
5) 2214320305
2|P age
Sr no Content Page no
1 Introduction of 4
python
2 Objectives 5
3 Scope of Project 6
4 Literature 8
Review
5 Implementation 10
6 Usermanual 13
7 Source Code 14
8 Output 15
9 Future work 16
Conclusion
10
3|P age
Introduction of python :-
Tac Tic Toe is traditionally played on a 3*3 grid. Players take turns placing a mark in one
of the cells of the grid. The goal of the game is for players to position their marks so that
they make a continuous line of three cells vertically , horizontally, or diagonally.The
game ends either when one player achieves this goal or when all spaces on the board are
filled, resulting in a draw. It’s a simple yet classic game often used to introduce basic
strategic thinking.
Tic-tac-toe, also known as noughts and crosses or Xs and Os, is a classic paper-and-pencil
game for two players. The players take turns marking spaces in a 3x3 grid with their
respective symbols, typically X and O, with the goal of getting three of their marks in a
row horizontally, vertically, or diagonally before their opponent does. It's a game of
strategy and often ends in a draw if both players play optimally.
The origins of tic-tac-toe trace back centuries, with some theories suggesting it
originated in ancient Egypt or Rome. However, the modern version of the game likely
evolved in Europe during the 18th or 19th centuries. It gained popularity as a pencil-and-
paper game in the 20th century, especially among schoolchildren.
The game's simplicity and accessibility contributed to its widespread adoption. Tic-tac-
toe's straightforward rules and minimal equipment requirements made it a popular
pastime in various cultures around the world. Over time, it has been adapted into digital
formats, including computer and mobile applications, further cementing its status as a
timeless classic.
2. *Critical thinking:* Playing tic-tac-toe involves analyzing the game board and making
decisions based on current positions and potential future outcomes. This can enhance
critical thinking abilities and decision-making skills.
4. *Teaching tool:* Tic-tac-toe is often used as an educational tool for teaching concepts
like game theory, logic, and even programming basics in a simple and accessible manner.
While tic-tac-toe may not have direct practical applications in professional or academic
settings, its simplicity and accessibility make it a valuable tool for developing various
cognitive
5|P age
Objectives :-
The primary objectives of the Tic Tac Toe project are as follows:
1. You are X, your friend (or the computer in this case) is O. Players take turns
putting their marks in empty squares
2. The first player to get 3 of her marks in a row (up, down ,across, or diagonally is
the winner
3. When all 9 squares are full, the game is over, if no player has 3 marks in a row the
game ends in a tie .d
6|P age
Scope of the Project;-
The Tic tac toe project will cover the following key functionalities:
- Tic tac toe is a game which can be played by people of all ages, anytime used in
enhancing the players thinking by teaching the concepts of good sportsmanship and the
branch of artificial intelligence that deals with the searching of game trees.
- The goal of the game is for players to position their marks so that they make a
continous line of three cells vertically, horizontally, or diagonally . An opponent can
prevent a win by blocking the completion of the opponent’s line. In our variant of the
game, players placed object on a board .
7|P age
Literature Review;-
The square block (3*3) can be filled with a cross(x) or a circle(o) in the Tic Tac Toe game
which can be played by two players. By allowing each player to mark their move, the game
will switch between the vertical or diagonal line with three identical markers the program
displays which plater has won whether X or O The game is constructed such that two players
can play tic tac toe by entering the position to place their marks on the board. The software
will have a display function and a select function for placing the symbol as well as a toggle
function for switching between the symbol as well as a toggle function for switching between
the symbols, allowing each participant to take a turn playing the game. After each player
makes a move, the computer will update and check for game circumstances as the game
progresses.
8|P age
Implementation;-
Here is the basic implementation of a two player Tic Tac Toe in python. For each
player (1 or 2) , calls the random_place() function to randomly choose a location on a
board and mark that location with the player number.To understand the program of tic
tac toe you should have a basic idea about the following python concepts :
1. Python Functions
2. Python Loops
9|P age
User Manual;-
Step 1
The following line initializes a list called board with 9 spaces, representing the 9
spaces on the Tic Tac Toe board.
Step 2
The following function print_board() will print the Tic Tac Toe board. It creates 3
strings, row1, row2, and row3, to represent each row of the board. The spaces in the
board are filled with the values from the board list. The function then prints each row
with separators to create the appearance of a 3×3 grid.
Step 3
The following function then prints each row with separators to create the appearance
of a 3×3 grid. The player_move() function allows a player to make a move by marking
a space on the board with their icon (X or O). It takes the player’s icon as an argument
and asks the player to enter their move (1-9) in the terminal. If the space the player
chooses is blank, the function will place the player’s icon in that space. Otherwise, it
will inform the player that the space is full.
Step 4
This function is_victory() checks if a player has won the game. It takes the player’s
icon as an argument and checks if there are three of that icon in a row on the board. It
returns True if a player has won, otherwise it returns False.
Step 5
This function is_draw() checks if the game is a draw by checking if all spaces on the
board are filled. When all spaces are filled and no player has won, it returns True,
otherwise it returns False.
Step 6
The while loop continues the game until a player has won or the game is a draw.
Within the loop, the board is printed. Then, the player_move() function calls and
allows the first player to make a move. The board prints again to show the updated
state. Then, calling the is_victory() function will check if the first player has won.
When they win, the game ends and a victory message shows If not, the is_draw()
10 | P a g e
function is called to check if the game is a draw.
If the game is a draw, a message is displayed and the game ends. If neither the first
player nor the game has won or ended in a draw, the second player makes a move and
the process repeats.
11 | P a g e
Source code;-
def get_rows(board):
return len(board)
def get_cols(board):
return len(board[0])
def get_piece_label(piece):
if piece == 1:
return "|" + Color.PURPLE + Color.BOLD + "X" + Color.END +
"|"
elif piece == 2:
return "|" + Color.BLUE + Color.BOLD + "O" + Color.END + "|"
12 | P a g e
else:
return Color.BOLD + "|_|" + Color.END
def print_board(board):
print("\n---------------------------------------------------------------------------
--------------------------------")
rows = get_rows(board)
cols = get_cols(board)
for row in range(rows):
for col in range(cols):
piece = get_piece(board, row, col)
label = get_piece_label(piece)
print(label, end="")
print()
def other_player(player):
return 1 if player == 2 else 2
def oops(msg):
print(" ", msg, Color.RED + Color.BOLD + "Try again." +
Color.END)
def read_int(prompt):
while True:
try:
return int(input(prompt))
except ValueError:
oops(Color.RED + Color.BOLD + "Input must be an integer." +
Color.END)
14 | P a g e
def finish():
answer = input(Color.PURPLE + Color.BOLD + """Would you like to
play again?! (press 'y' for yes and 'n' for no):""" + Color.END)
if answer.lower() == "n":
print("")
print(Color.BLUE + Color.BOLD + "Bye Bye! See you next time!
:)" + Color.END)
return True
if answer.lower() == "y":
print(Color.BLUE + Color.BOLD + """\nGreat choice! The game
will start again""" + Color.END)
return False
def play_tic_tac_toe():
rows, cols = 3, 3
win_length = 3
board = make_new_board(rows, cols)
moves = 0
player = 1
def main():
while True:
play_tic_tac_toe()
if finish():
15 | P a g e
break
if _name_ == '_main_':
main()
Module;-
# color.py
class Color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
16 | P a g e
Output;-
17 | P a g e
future work:-
Future work includesclassic game contributes to children's developmental
growth in numerous ways including their understanding of predictability,
problem solving, spatial reasoning, hand-eye coordination, turn taking, and
strategizing.
18 | P a g e
Conclusion;-
In conclusion, The player who succeeded in placing three respective marks in a
horizontal, vertical, or diagonal row wins the game. The Tic Tac Toe is a great way to
pass your free time whether you're standing in a line or spending time
19 | P a g e
Weekly Work / Progress Report
Details of 16 Engagement Hours of the Student Regarding
Completion of the Project
No. Date Timing Week Work Or Activity Sign Of
Performed The
Guide
From To Duration In
Hours
1 02/01/2024 2:00 5:00 3 Discussion and
Finalization of the
Project Title
2 09/01/2024 2:00 3:00 1 Preparation and
submission of
Abstract
3 16/01/2024 2:00 3:00 1 Literature review
20 | P a g e
Annexure:-
21 | P a g e
Remark :-
3112 Rajnandeeni
Rajendra Pati
22 | P a g e
Reference:-
https:/ /en.m.wikipedia.org
https://www.wikihow.com
Chat GPT
23 | P a g e
24 | P a g e
25 | P a g e
26 | P a g e