0% found this document useful (0 votes)
296 views9 pages

Python Tic-Tac-Toe Micro Project

The document provides details about developing a Tic-Tac-Toe game using Python. It includes the rationale for the project, its aims, literature reviewed, actual procedures followed including the program code, and course outcomes achieved. The objective is to create a two-player strategy board game on a 3x3 grid where players alternate placing Xs and Os until one wins by having three in a row, or the board is full to a draw.

Uploaded by

Avi Borkar
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)
296 views9 pages

Python Tic-Tac-Toe Micro Project

The document provides details about developing a Tic-Tac-Toe game using Python. It includes the rationale for the project, its aims, literature reviewed, actual procedures followed including the program code, and course outcomes achieved. The objective is to create a two-player strategy board game on a 3x3 grid where players alternate placing Xs and Os until one wins by having three in a row, or the board is full to a draw.

Uploaded by

Avi Borkar
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
  • Aim of the Project
  • Rationale
  • Literature Review
  • Course Outcomes Achieved
  • Actual Procedure Followed
  • Actual Resources Required
  • Skill Developed/ Learning Outcomes
  • Applications of the Project

A

Report On
“Tic-Tac-Toe Game”
Under the subject
‘Programming with Python [22616]’

P
AP
Submitted by

n
tio
Sr. No Enrollment No Name of the student
lu
1 1700100271 Miss. Shinde Mohini Anandrao
So

2 1700100276 Miss. Jagtap Sakshi Krushna


TE
SB

Under the guidance of


Mr. Emekar S. P
M

Department of Computer Engineering


Government Polytechnic, Karad
1.0 Rationale
The objective of this project is to develop the well-known board game Tic-Tac-
Toe for two players.
Generally, this is a two-player strategy board game. The Tic-Tac-Toe game is
based on having a game board (2D array) of size 3 x 3. The players alternate placing Xs
and Os on the board until either one has placed three Xs or Os in a row horizontally,
vertically, or diagonally; or all nine board squares are filled. The player wins if s/he
draws three Xs or three Os in a row. Otherwise, the game is draw.
Initially the board grid squares are initialized to zeros. Xs and Os might be
denoted by numbers inside the board grid by ones and twos respectively. I.e. if player one
chooses X, the location of that choice is registered as 1 and when player two chooses O
the location of that choice in your array is registered as 2. At the end if a row of 1s is

P
registered then player one won the game. Or if a row of 2s is registered thus player two

AP
won the game. If not, the game is draw. The game ends when there is no more empty
fields in the array (board) to fill or if one of the players wins the game.

2.0 Aim of the project


n
tio
1. To develop an interesting game for children to pass their free time.
lu
2. To develop the well-known board game Tic-Tac-Toe for two players.
3. To be one of the players to get three same symbols in a row – horizontally, vertically or
So

diagonally on a 3 x 3 grid.
TE

3.0 Course Outcomes Achieved


1. Display message on screen using Python script on IDE.
SB

2. Develop python program to demonstrate use of Operators.


3. Perform operations on data structures in Python.
4. Develop functions for given problems.
M

4.0 Literature Review


Author (Publication) Abstract Conclusion
Kalyani Adawadkar This paper describes the main We used this paper to learn
(Sigma Institute of features and applications of different features available in
Engineering) Python Programming Python and its applications.
David Beazley This book contains a complete We used this book to learn the
(Sams Publishing) learning of Python Programming basic concepts of Python
Programming
Tom Gutschmidt This book covers game We used this book to learn how to
(Premier Press) programming in three different build efficient, flexible and well-
scripting languages i.e, Python, Lua integrated programs and systems
and Ruby
Table 1- Literature Review
5.0 Actual procedure followed
Actual procedure followed during the project is mentioned in the table below with
the planned start date and completed finish date.
[Link] Details of activity Planned Planned Name of responsible
Start date Finish date Team members
1. Decide project topic 16/12/2019 23/12/2019 1. Shinde Mohini
2. Jagtap Sakshi
2. Decide features of project 23/12/2019 06/01/2020 1. Shinde Mohini
2. Jagtap Sakshi

P
3. Prepare project proposal 06/01/2020 13/01/2020 1. Shinde Mohini
2. Jagtap Sakshi

AP
4. Decide different data 13/01/2020 27/01/2020 1. Shinde Mohini
structures 2. Jagtap Sakshi

n
5. Develop actual program 27/01/2020 17/02/2020
tio 1. Shinde Mohini
code 2. Jagtap Sakshi
6. Debug the program code 17/02/2020 02/03/2020 1. Shinde Mohini
lu
2. Jagtap Sakshi
So

7. Preparing final project report 02/03/2020 16/03/2020 1. Shinde Mohini


2. Jagtap Sakshi
TE

Table 2- Actual procedure followed


SB

 Program code
M

#Implementation of Two Player Tic-Tac-Toe game in Python.

theBoard = {'1': ' ' , '2': ' ' , '3': ' ' ,
'4': ' ' , '5': ' ' , '6': ' ' ,
'7': ' ' , '8': ' ' , '9': ' ' }

board_keys = []

for key in theBoard:


board_keys.append(key)

def printBoard(board):
print("\n")
print(' '+board['1'] + ' | ' + board['2'] + ' | ' + board['3'])
print(' ---+---+---')
print(' '+board['4'] + ' | ' + board['5'] + ' | ' + board['6'])
print(' ---+---+---')
print(' '+board['7'] + ' | ' + board['8'] + ' | ' + board['9'])
print("\n")

# Now we'll write the main function which has all the gameplay functionality.
def game():

turn = 'X'

P
count = 0

AP
for i in range(10):
printBoard(theBoard)

n
move=input("It's your turn," + turn + ". Move to which place? ")
tio
#move = input()
lu
So

if theBoard[move] == ' ':


theBoard[move] = turn
count += 1
TE

else:
print("THAT PLACE IS ALREADY FILLED.\nMove to which place?")
continue
SB

# Now we will check if player X or O has won,for every move after 5 moves.
M

if count >= 5:
if theBoard['1'] == theBoard['2'] == theBoard['3'] != ' ': # across the top
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
break
elif theBoard['4'] == theBoard['5'] == theBoard['6'] != ' ': # across the middle
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
break
elif theBoard['7'] == theBoard['8'] == theBoard['9'] != ' ': # across the bottom
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
break
elif theBoard['7'] == theBoard['4'] == theBoard['1'] != ' ': # down the left side
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
break

P
elif theBoard['8'] == theBoard['5'] == theBoard['2'] != ' ': # down the middle

AP
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME

n
******\n\n")
tio
break
elif theBoard['9'] == theBoard['6'] == theBoard['3'] != ' ': # down the right side
lu
printBoard(theBoard)
So

print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
TE

break
elif theBoard['1'] == theBoard['5'] == theBoard['9'] != ' ': # diagonal
printBoard(theBoard)
SB

print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
M

******\n\n")
break
elif theBoard['7'] == theBoard['5'] == theBoard['3'] != ' ': # diagonal
printBoard(theBoard)
print("\nGAME OVER.\n\n")
print(" ****** CONGRATULATIONS! " +turn + " YOU WON THE GAME
******\n\n")
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\n")
print("*** IT'S A TIE!! ***\n\n")
break

# Now we have to change the player after every move.


if turn =='X':
turn = 'O'
else:
turn = 'X'

# Now we will ask if player wants to restart the game or not.


restart = input("Do want to play Again?(y/n)")
if restart == "y" or restart == "Y":
for key in board_keys:

P
theBoard[key] = " "

AP
game()

n
if __name__ == "__main__":
tio
game()
lu
Output:
So
TE
SB
M

Fig 1: Tic Tac Toe Game Board


P
AP
n
Fig 2: Message displayed if you choose the position which is already chosen
tio
lu
So
TE
SB
M

Fig 3: Message displayed after winning the game


P
AP
n
Fig 4: Message displayed after losing the game
tio
lu
So

6.0 Actual Resources Required


TE

The resources used during the completion of project are mentioned in the below
[Link] Name of resources Specifications Quantity Remarks
SB

material
1. YouTube MP4-file format, 640 x 1
M

360 pixels
2. Microsoft Word 2010 version 1

3. IDLE Version 3.8.1 1

4. Laptop Dell, RAM 8 GB, 1


Harddisk 1 TB, i3
processor
8.0 Skill Developed/ learning out of this Micro-Project
We learnt,
1. To demonstrate the use of Operators.
2. To perform operations on data structures in Python.
3. To develop functions for given problems.
4. Efficient communication skills.
5. Working as a team member for developing c program.
6. Developing leadership qualities.

9.0 Applications of the Project

P
1. Thisproject can be used as an interesting game for children to pass their free time.

AP
2. The project can be also used to understand the.
3. The project can be used in learning the

n
tio
lu

Subject Teacher
So

Mr. Emekar S. P
TE
SB
M

Common questions

Powered by AI

The Tic-Tac-Toe game demonstrates the use of Python operators through its gameplay logic, where logical operators are used to check winning conditions on the board. The equality operator (==) checks if the same marker exists across a winning line (rows, columns, or diagonals). Additionally, the assignment operator (=) updates the board state with the player's move, and input/output operations manage interactions with the player .

Through the Tic-Tac-Toe project, developers enhanced their understanding of Python concepts such as operators and data structures. They gained experience in problem-solving by developing functions and modular code. Additionally, they improved soft skills like communication, teamwork, and leadership, critical for effective collaboration and project management .

Teamwork was pivotal in the Tic-Tac-Toe project's success as it allowed for effective division of tasks, where each team member brought unique skills and perspectives. This collaborative approach enabled efficient problem-solving during coding and debugging phases, and ensured timely project completion by leveraging each member's strengths in planning and executing project goals .

The use of a 2D array in the Tic-Tac-Toe game enhances gameplay mechanics by providing a straightforward representation of the 3x3 grid. This array is used to track player moves, facilitate checks for winning conditions by examining rows, columns, and diagonals, and determine if the game has ended in a win or draw when the array is full, thus structuring the game logic efficiently .

Debugging played a crucial role in the Tic-Tac-Toe development process as it ensured the program's reliability and functionality. By identifying and resolving logical errors, such as improper game state updates and winning condition checks, the developers could refine the game's operation, providing an error-free user experience. This step was vital for completing the project successfully with robust code .

The developers explored Python's broad applications and features, including its use in game development, by reviewing literature that covered Python's capabilities, syntax, and efficiency in building robust programs. Key sources included learning materials on the fundamentals and application of Python in different scripting languages, enhancing their programming proficiency .

Developing a Tic-Tac-Toe game can enhance learning outcomes in Python programming by providing practical experience with data structures like dictionaries to manage the game state. It also reinforces concepts of control structures through gameplay logic for turn-taking and win/tie checking, use of functions for modular code, and debugging skills while ensuring that the program runs effectively in various gameplay scenarios .

Python's flexibility allows developers to quickly implement changes and iterate over game features due to its intuitive syntax and dynamic typing. Its integration capabilities ensure easy interaction with various libraries and tools, facilitating aspects like GUI implementation and testing. These benefits make Python a suitable choice for developing games like Tic-Tac-Toe, where simplicity and iterative design are critical .

The main resources included software tools like IDLE for coding, Microsoft Word for documentation, and online resources such as YouTube for tutorials. A laptop with specific hardware configurations supported efficient development and testing procedures. These resources were integral for programming, debugging, and project communication, directly influencing the project's satisfactory completion .

The project management strategies included establishing a timeline for each development phase, from deciding the project topic to debugging and finalizing the report. Each stage had a planned start and finish date, ensuring structured progress. Collaboration was managed by dividing responsibilities between Shinde Mohini and Jagtap Sakshi, maintaining clear communication and effective teamwork .

A 
Report On 
“Tic-Tac-Toe Game” 
Under the subject 
‘Programming with Python [22616]’ 
 
Submitted by 
 
 
 
Under the gui
1.0 Rationale 
The objective of this project is to develop the well-known board game Tic-Tac-
Toe for two players. 
Generally
5.0 Actual procedure followed  
                     Actual procedure followed during the project is mentioned in the table
print("
") 
print('           '+board['1'] + ' | ' + board['2'] + ' | ' + board['3']) 
print('          ---+---+---') 
p
elif theBoard['7'] == theBoard['8'] == theBoard['9'] != ' ': # across the bottom 
printBoard(theBoard) 
print("
GAME OVER.
break 
 
        # Now we have to change the player after every move.
        if turn =='X': 
            turn =
Fig 2: Message displayed 
Fig 3: Message displayed after winning 
Message displayed if you choose the position which is alrea
Fig 4: Message displayed after losing the game
6.0 Actual Resources Required
                         The resources used duri
8.0 Skill Developed/ learning out of this Micro-Project 
 
We learnt, 
1. To demonstrate the use of Operators. 
2. To perform

You might also like