Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

MINI PROJECT REPORT

on
“ TIC TAC TOE ’’
Submitted in fulfillment of the requirements
For the degree of

BACHELOR OF COMPUTER ENGINEERING


BY

Saurabhkumar Yadav (SE-A-147)


Vishal Gupta (SE-A-159)
Vishal Yadav (SE-A-160)
Under the guidance of
Prof. Shital K. Dhamal

LOKMANYA TILAK COLLEGE OF ENGINEERING


Department Of Computer Engineering
YEAR 2022-2023

CERTIFICATE

This is to certify that the mini project entitled “ ” is a bonafide work of ‘Name’ Roll
no- (SE-A), ‘Name’ Roll no (SE-A) and ‘Name’ Roll no (SE-A) . It is submitted to
the University of Mumbai in fulfillment of the requirement for the award.
Prof. Shital K. Dhamal
Guide
ACKNOWLEDGEMENT

Here we gladly present this mini project report on “ ” as a part of the 4th semester BE in Computer
Engineering. At this time of submitting this report, we use this opportunity to mention those people
who were with us for this work. We extend our sincere and heartfelt thanks to our esteemed guide,
Prof. Shital Dhamal for providing us with the right guidance and advice at crucial junctures and for
showing us the right way.

Name of the Student Name of the Student Name of the Student


INDEX

Sr. No. Contents Page No.

1 Introduction 5

2 Program 7-9

3 Output Screenshots 10

4 Conclusion 10
INTRODUCTION:-
Tic-tac-toe is a straightforward two-player game that, if both players play
their best, will always end in a tie. The game is also known as Xs and Os or
zeros and crosses. A computer or other device can be used to play the game
of tic tac toe, which is typically played by drawing on paper.

o The game must be played by two players (in this program between
PLAYER 1 and PLAYER 2).
o Both players mark their cells with the letters "O" and "X".
o The game ends when one of the players fills an entire row, column or
diagonal with either the character ('O' or 'X') of that player.
o If no one wins, the match is considered a draw.
Program:-
#include <stdio.h>
#include <conio.h>

char square[10] = { 'o', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

int checkwin();
void board();

int main()
{
int player = 1, i, choice;

char mark;
do
{
board();
player = (player % 2) ? 1 : 2;

printf("Player %d, enter a number: ", player);


scanf("%d", &choice);

mark = (player == 1) ? 'A' : 'B';

if (choice == 1 && square[1] == '1')


square[1] = mark;

else if (choice == 2 && square[2] == '2')


square[2] = mark;

else if (choice == 3 && square[3] == '3')


square[3] = mark;

else if (choice == 4 && square[4] == '4')


square[4] = mark;

else if (choice == 5 && square[5] == '5')


square[5] = mark;

else if (choice == 6 && square[6] == '6')


square[6] = mark;

else if (choice == 7 && square[7] == '7')


square[7] = mark;

else if (choice == 8 && square[8] == '8')


square[8] = mark;
else if (choice == 9 && square[9] == '9')
square[9] = mark;

else
{
printf("Invalid move ");

player--;
getch();
}
i = checkwin();

player++;
}while (i == - 1);

board();

if (i == 1)
printf("==>\aPlayer %d win ", --player);
else
printf("==>\aGame draw");

getch();

return 0;
}

int checkwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;

else if (square[4] == square[5] && square[5] == square[6])


return 1;

else if (square[7] == square[8] && square[8] == square[9])


return 1;

else if (square[1] == square[4] && square[4] == square[7])


return 1;

else if (square[2] == square[5] && square[5] == square[8])


return 1;

else if (square[3] == square[6] && square[6] == square[9])


return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;

else if (square[3] == square[5] && square[5] == square[7])


return 1;

else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
square[4] != '4' && square[5] != '5' && square[6] != '6' && square[7]
!= '7' && square[8] != '8' && square[9] != '9')

return 0;
else
return - 1;
}

void board()
{
system("cls");
printf("\n\n\tTic Tac Toe\n\n");

printf("Player 1 (A) - Player 2 (B)\n\n\n");

printf(" | | \n");
printf(" %c | %c | %c \n", square[1], square[2], square[3]);

printf("_____|_____|_____\n");
printf(" | | \n");

printf(" %c | %c | %c \n", square[4], square[5], square[6]);

printf("_____|_____|_____\n");
printf(" | | \n");

printf(" %c | %c | %c \n", square[7], square[8], square[9]);

printf(" | | \n\n");
}
Output Screenshot:-

Conclusion:-
The Tic Tac Toe game is most familiar among all the age groups.
Intelligence can be a property of any purpose-driven decision maker. This
basic idea has been suggested many times. An algorithm of playing Tic Tac
Toe has been presented and tested that works in efficient way. Overall the
system works without any bugs.

You might also like