Approval
Approval
Program: BS-CS
Batch: 2024-2028
Submitted By
Ali Hamza
Muhammad Haroon 14
Muhammad Amir 19
STATEMENT OF SUBMISSION
This is to certify that Ali Hamza Roll No , Muhammad Haroon Roll No.
14,Muhammad Amir Roll No.19 have successfully completed the final semester
project name as game “tic tac toe” at the faculty of CS, Al-Shifa Institute of
Health Science Narowal, to fulfil the partial requriment of the degree of
Bacheloys in computer science.
By
Ali Hamza
Muhammad Haroon
Muhammad Amir
DEGREE
University of AIHS
Session 2024-2028
ACKNOWLEDGEMENTS
Ali Hamza:
Muhammad Haroon:
Muhammad Amir:
INTRODUCTION
This project is a console-based implementation of the classic Tic Tac Toe game developed using C++. It
is designed as part of our final semester project, focusing on basic concepts of arrays, control structures,
functions, and console manipulation.
The game is built for two players (Player 1 as 'X' and Player 2 as 'O') who take turns marking spaces in a
3×3 grid. The first player to align three of their marks in a horizontal, vertical, or diagonal row wins the
game. If all positions are filled and no player wins, the game results in a draw.
The project not only demonstrates logical structuring and game design fundamentals, but also provides an
engaging user experience in a simple terminal environment.
Tic Tac Toe, also known as "Noughts and Crosses," is a simple yet engaging two-player game that has been
popular for decades. Traditionally played on paper, it involves two players taking turns to mark spaces in a
3×3 grid, aiming to place three of their marks in a row—horizontally, vertically, or diagonally.
In the realm of programming and software development, Tic Tac Toe is commonly chosen as a beginner-
level project due to its straightforward logic and manageable implementation. It helps learners grasp
fundamental programming concepts such as loops, conditionals, functions, arrays, and user input handling.
Existing System:
The traditional implementation of Tic Tac Toe has been done in various programming languages and
platforms—ranging from paper-based and mobile apps to web and graphical interfaces. However, most
existing implementations either:
Are GUI-based and rely on external frameworks or libraries (e.g., using JavaFX, Python Tkinter, or
Unity).
Provide minimal interactivity when done via console, often lacking color, sound, or real-time
feedback.
Have limited user experience features such as proper input validation, error handling, or replay
options.
Our project aims to enhance the standard console-based Tic Tac Toe by introducing a more interactive and
visually appealing user experience using C++ and Windows console functions. This includes:
By doing so, we bridge the gap between a simple console-based game and a more immersive experience—
all without needing any external libraries or advanced GUI frameworks.
Problem Statement
Traditional Tic Tac Toe games are either played on paper or implemented in very basic formats via console or GUI
applications. However, most implementations lack the aesthetic presentation, player-friendly feedback, and
immersive features such as audio cues and colored UI.
Existing System
This program is a console-based two-player Tic Tac Toe game, implemented in C++ with added visual and sound
features for enhanced user experience.
Proposed System
The proposed system is a fully interactive two-player Tic Tac Toe game developed in C++, designed to overcome the
limitations of traditional console-based implementations. It integrates colorful visuals, sound effects, and robust
input handling to deliver a more engaging and user-friendly experience.
2. Audio Feedback:
Employs the Beep() function to generate distinct tones when a player makes a move:
Provides auditory cues for improved immersion.
4. Win/Draw Detection:
6. Exit Option:
Main Modules
1. Global Variables
2. setColor(int color)
3. display_board()
Clears the screen and draws the game board using color-coded tiles for X (green), O (red), and numbers
(white).
Visually structured and uses ASCII box drawing.
4. play_sound(char player)
5. player_turn()
6. gameover()
Checks for:
o Winning conditions (rows, columns, diagonals).
o Draw condition (no empty spaces left).
Returns true if the game is still going, false otherwise.
7. main()
Expected Outcome
1. Welcome Screen
When the game starts, it shows a colorful welcome message with credits:
Each number represents a spot a player can pick. As players pick spots, numbers are replaced with X or O, colored
accordingly:
If a player enters:
A valid number (1–9): Game updates the board and plays a beep.
0: Exits the game with a goodbye message.
Invalid input (non-number or out of range): Shows an error and re-prompts.
4. Sound Effects
✅ Functional Requirements
🛠 Non-Functional Requirements
1. Platform Dependency
o Uses Windows-specific headers and functions:
windows.h for Beep() and console color.
system("cls") for screen clearing.
Not portable to Unix/Linux without modification.
2. User Experience
o Engaging via color, sound, and layout.
o Clearly communicates errors and guides the user.
3. Performance
o Lightweight and runs smoothly on standard consoles.
o Efficient checking logic for win/draw conditions
TESTING
1) Sound problem
Solve :
void play_sound(char player)
{
if (player == 'X')
{
Beep(750, 300);
}
else if (player == 'O')
{
Beep(500, 300);
}
}
2) Exit problem
Solve :
3)Restart problem
Solve :
sleep(2);
}
CONCLUSION & FUTURE WORK
Conclusion
The Tic Tac Toe game successfully provides an interactive and visually appealing experience for two players. With a
colorful console UI, basic sound feedback, and proper input handling, it brings a traditional paper-and-pencil game to
life in a digital format. The game logic correctly handles win conditions, draws, and input validation, ensuring a
smooth and error-free user experience. The inclusion of player turn indicators and feedback for invalid inputs further
enhances the usability of the game.
Future Work
1. AI Opponent: Introduce a single-player mode with an AI opponent using minimax or heuristic logic.
2. Mouse Input Support: Use Windows API for mouse input to make gameplay more intuitive.
3. Save & Load Feature: Allow players to save the game state and resume later.
4. Score Tracking: Keep track of scores across multiple rounds for both players.
5. Enhanced UI Elements: Add animations or graphical elements using a game library like SFML or SDL.
6. Cross-Platform Support: Refactor the code to remove Windows-specific dependencies like windows.h and
Beep(), making it compatible with Linux/MacOS.
7. Sound Customization: Allow players to choose or mute game sounds.
8. Difficulty Levels: For single-player mode, add difficulty settings to make the AI more or less challenging