TIC TAC TOE REPORT (PDF)
TIC TAC TOE REPORT (PDF)
TIC TAC TOE REPORT (PDF)
Bachelor of Technology
in
Submitted by
VIVEK KUMAR
Session-2023-2024
Vision of the Department
M3. To develop habitude of research among faculty and students in the area of
Computer Science & Allied disciplines by providing the desired environment, for
addressing the needs of industry and society.
M4. To mould the students with ethical principles in thoughts, expression and
deeds.
Index
1 Introduction
………………………………………………...
2 Requirement
………………………………………………..
3 Conceptual Background
……………………………………
4 Implementation
………………………………………….....
4.1 Coding
…………………………………………………
5 User Interface
………………………………………………
6 Future Scope
………………………………………………
References
…………………………………………………
Chapter-1
Introduction
To create a simple Tic Tac Toe game in C, you'll need the following basic requirements:
1. *Game Board:* Set up a 3x3 grid to represent the Tic Tac Toe board.
2. *Players:* Implement logic for two players to take turns, marking an 'X' or 'O' on the board.
3. *Winning Condition:* Check for a winning condition after each move to determine if a
player has won.
4. *Draw Condition:* Check for a draw if the board is full and there is no winner.
6. *Display Board:* Show the current state of the board after each move.
7. *Game Loop:* Create a loop that continues until there's a winner or a draw.
Certainly, let's delve into the conceptual background of a Tic Tac Toe game.
1. *Game Board:*
- The game is played on a 3x3 grid, providing a total of 9 cells.
- Each cell can be empty, marked with an 'X' for Player 1, or an 'O' for Player 2.
2. *Players:*
- Typically, two players take turns making moves.
- Player 1 is assigned 'X', and Player 2 is assigned 'O'.
3. *Winning Condition:*
- A player wins if they have three of their marks in a row (horizontal, vertical, or diagonal).
- The game checks for these winning conditions after each move.
4. *Draw Condition:*
- If the board is full and no player has won, the game is a draw.
5. *User Input:*
- Players input their moves by specifying the row and column where they want to place their
mark.
- Input validation ensures that the chosen cell is empty and within the valid range.
6. *Display Board:*
- The current state of the board is displayed after each move.
- This helps players visualize the progression of the game.
7. *Game Loop:*
- The game is played in a loop until there is a winner or a draw.
- After each turn, the loop continues, allowing players to take alternating turns.
8. *Error Handling:*
- The program should handle invalid inputs gracefully, guiding players to enter correct and
legal moves.
9. *Restart Option:*
- After the game concludes (either a win or a draw), players may choose to restart the game.
Implementation Overview:
- The program consists of functions to initialize the board, display the board, handle player
moves, and check for win/draw conditions.
- A main game loop orchestrates these functions, making the game interactive and responsive
to player input.
Understanding these concepts provides a foundation for implementing the Tic Tac Toe game
in C or any other programming language.
Chapter-4
IMPLEMENTATION
4.1 Coding:
#include <stdio.h>
#include <conio.h>
void printBoard();
int checkWin();
void system();
char board[]={'0','1','2','3','4','5','6','7','8','9'};
void main(){
int player=1,input,status=-1;
printBoard();
while (status==-1)
player=(player%2==0) ? 2 : 1;
scanf("%d",&input);
if(input<1 || input>9){
printf("invalid input");
board[input]=mark;
printBoard();
int result=checkWin();
if(result==1){
return;
}else if(result==0){
printf("draw");
return;
player++;
void printBoard(){
system("cls");
printf("\n\n");
printf(" | | \n");
printf(" %c | %c | %c \n",board[1],board[2],board[3]);
printf("__|_|__\n");
printf(" | | \n");
printf(" %c | %c | %c \n",board[4],board[5],board[6]);
printf("__|_|__\n");
printf(" | | \n");
printf(" %c | %c | %c \n",board[7],board[8],board[9]);
printf(" | | \n");
printf("\n\n");
int checkWin(){
return 1;
return 1;
return 1;
}
return 1;
return 1;
return 1;
return 1;
return 1;
int count=0;
if(board[i]=='X' || board[i]=='O'){
count++;
if(count==9){
return 0;
return -1;
}
Chapter-5
User Interfaces
Chapter-6
Future Scope
The Tic Tac Toe game, while simple, can serve as a foundation for more advanced concepts
and features. Here are some ideas for extending the game and exploring its future scope:
2. *Networked Multiplayer:*
- Implement a networked multiplayer version, allowing players to compete against each other
over the internet.
- Explore concepts like client-server architecture for online gameplay.
4. *Scoring System:*
- Add a scoring system to track players' performance over multiple games.
- Include features like win streaks and achievements.
9. *Mobile Application:*
- Develop a mobile version of the game for iOS and Android platforms.
- Optimize the interface for touchscreens and provide a seamless mobile gaming experience.
10. *Localization:*
- Add support for multiple languages, making the game accessible to a broader audience.
- Allow users to choose their preferred language for the game interface.
By expanding the Tic Tac Toe game with these features, you can transform it from a simple
console application into a more sophisticated and enjoyable experience, catering to a wider
range of users.
References
1. *Books:*
- [GeeksforGeeks C Programming](https://www.geeksforgeeks.org/c-programming-
language/): A comprehensive resource for C programming.
- [C Programming Wikibook](https://en.wikibooks.org/wiki/C_Programming): A
collaborative resource for learning C programming.
3. *Game Development:*