Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views16 pages

TIC TAC TOE REPORT (PDF)

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 16

A

Mini Project/ Summer Training Report


On

“TIC TAC TOE(GAME)”


Submitted in partially fulfilment for the requirement for the award of the degree
of

Bachelor of Technology

in

Computer science and engineering

Submitted by

VIVEK KUMAR

Uni. Roll No.-2202840100252

Under the Supervision of


Trainer Name
BHANU PRATAP RAI

Department of Computer Science & Engineering

UNITED ISTITUTE OF TECHNOLOGY (284)

(Affiliated to Dr. A.P.J. Abdul Kalam Technical University, Lucknow)

Session-2023-2024
Vision of the Department

To be a center of excellence in the field of Computer Science and Engineering


for producing talented engineers to ethically serve constantly changing needs of
society and industry throughout their career and life.

Mission of the Department

M1. Accomplish excellence with committed faculty by providing theoretical


foundation and practical skills for solving complex engineering problems in the
state-of-the-art trends in Computer science and allied disciplines.

M2. To foster skills and competency, generating novel ideas, entrepreneurship


and model creations focused towards deep knowledge, interpersonal skills and
leadership.

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

S. No Topic Page No.

1 Introduction
………………………………………………...

2 Requirement
………………………………………………..

3 Conceptual Background
……………………………………

4 Implementation
………………………………………….....

4.1 Coding
…………………………………………………

4.2 Flow Chart


……………………………………………..

5 User Interface
………………………………………………

6 Future Scope
………………………………………………

References
…………………………………………………
Chapter-1
Introduction

A mini project in C for Tic-Tac-Toe involves creating a console-based game where


two players take turns to mark 'X' or 'O' on a 3x3 grid. The goal is to achieve a winning
combination of three marks in a row, column, or diagonal. The program should handle
user input, validate moves, display the updated board, and determine the winner or a
draw. It's a great project for practicing control structures, arrays, and basic game logic
in C programming.To implement the Tic-Tac-Toe game in C, you'll need to consider
functions for player input, checking for a winner, updating the game board, and
handling the game loop. Use a 2D array to represent the game board, and implement
logic to validate moves and detect a winning condition. The program should display the
board after each move and prompt players for their input. Ensure error handling for
invalid moves and terminate the game when there's a winner or a draw. This project
allows you to reinforce your understanding of arrays, loops, functions, and conditional
statements in C.
Chapter-2
Requirement

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.

5. *User Input:* Allow players to input their moves.

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.

8. *Error Handling:* Handle invalid inputs gracefully.

9. *Restart Option:* Provide an option to restart the game after it concludes.


Chapter-3
Conceptual Background

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;

char mark=(player==1) ? 'X' :'O';

printf("Please enter Number For Player %d\n",player);

scanf("%d",&input);

if(input<1 || input>9){

printf("invalid input");

board[input]=mark;

printBoard();

int result=checkWin();

if(result==1){

printf("Player %d is the Winner",player);

return;

}else if(result==0){
printf("draw");

return;

player++;

void printBoard(){

system("cls");

printf("\n\n");

printf("=== TIC TAC TOE ===\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(){

if(board[1]==board[2] && board[2]==board[3]){

return 1;

if(board[1]==board[4] && board[4]==board[7]){

return 1;

if(board[7]==board[8] && board[8]==board[9]){

return 1;
}

if(board[3]==board[6] && board[6]==board[9]){

return 1;

if(board[1]==board[5] && board[5]==board[9]){

return 1;

if(board[3]==board[5] && board[5]==board[7]){

return 1;

if(board[2]==board[5] && board[5]==board[8]){

return 1;

if(board[4]==board[5] && board[5]==board[6]){

return 1;

int count=0;

for (int i = 1; i <=9; i++)

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:

1. *Graphical User Interface (GUI):*


- Enhance the user experience by transitioning from a console-based interface to a graphical
one.
- Use graphics libraries or frameworks to create a visually appealing game board.

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.

3. *Artificial Intelligence (AI) Opponent:*


- Develop an AI opponent that players can compete against.
- Implement various difficulty levels for the AI, introducing strategic decision-making.

4. *Scoring System:*
- Add a scoring system to track players' performance over multiple games.
- Include features like win streaks and achievements.

5. *Customizable Board Size:*


- Allow players to choose different board sizes, expanding beyond the standard 3x3 grid.
- Implement logic to handle larger grids and adapt the win/draw conditions accordingly.

6. *Animations and Sound Effects:*


- Incorporate animations and sound effects to make the game more engaging.
- Provide visual and auditory feedback for successful moves, wins, and draws.

7. *Persistent User Profiles:*


- Introduce user profiles with saved game history and statistics.
- Allow players to customize their profiles with avatars or themes.
8. *Tournaments and Leaderboards:*
- Create a tournament mode where players can compete in a series of matches.
- Implement leaderboards to showcase top players based on their performance.

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:*

- "C Programming Absolute Beginner's Guide" by Perry and Miller.

- "C Programming for the Absolute Beginner, Second Edition" by Vine.

- "Programming in C" by Kochan.

2. *Websites and E-Books:*

- [GeeksforGeeks C Programming](https://www.geeksforgeeks.org/c-programming-
language/): A comprehensive resource for C programming.

- [Learn C.org](https://www.learn-c.org/): An interactive C tutorial.

- [C Programming Wikibook](https://en.wikibooks.org/wiki/C_Programming): A
collaborative resource for learning C programming.

3. *Game Development:*

- [GameDev.net](https://www.gamedev.net/): A community and resource hub for game


developers.

- [Unity Learn](https://learn.unity.com/): If you're interested in game development with C#,


Unity is a popular choice.
APPENDIX

You might also like