CGR Microproject
CGR Microproject
A Project Report
On
PROF. H.A.PUNDAPAL
SANT GAJANAN MAHARAJ RURAL POLYTECHNIC MAHAGAON
ACADEMIC YEAR
2023 – 2024
1
Maharashtra State Board of Technical Education, Mumbai.
CERTIFICATE
THIS IS TO CERTIFY THAT THE FOLLOWING STUDENTS OF SECOND YEAR.
THIRD SEMESTER OR DIPLOMA IN COMPUTER ENGINEERING OF
INSTITUTE SANT GAJANAN MAHARAJ RURAL POLYTECHNIC, MAHAGAON
– (CODE)416502 HAS COMPLETED MICRO PROJECT—TIC-TAC-TOE GAME
IN SUBJECT – COMPUTER GRAPHICS CODE- 22318 FOR ACADEMIC YEAR
2023-2024
2
INDEX
1 AIM 4
2 COURSE OUTCOME 4
3 METHODOLGY 4
4 RESOURCES USED 4
5 SCOPE OF PROJECT 5
6 BRIEF INTRODUCTION 5
7 RULES 6
8 PROGRAM CODE 6
9 OUTPUT 10
● COURSE OUTCOME :-
● METHODOLGY :-
● RESOURCES USED :-
3 REFERENCE - -
● BRIEF INTRODUCTION :-
The Tic Tac Toe game is a game for two players, called "X" and "O", who take turns
marking thespaces in a 3×3 grid. The player who succeeded in placing three respective
marks in a horizontal,vertical, or diagonal row wins the game. The Tic Tac Toe is a great way
to pass your free timewhether you're standing in a line or spending time with your kids.
Stop wasting paper and savetrees. Because of the simplicity of Tic Tac Toe, is it is often used as
a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence.
● CODE :-
6
#include <stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void initialize_board(char board[3][3])
{
int i,j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++) {
board[i][j] = ' ';
}
}
}
void display_board(char board[3][3])
{
int i,j;
printf("\n 1 2 3\n");
for (i = 0; i < 3; i++)
{
printf("%d ", i + 1);
for ( j = 0; j < 3; j++)
{
printf("%c", board[i][j]);
if (j < 2)
{
printf("|");
}
}
7
printf("\n");
if (i < 2) {
printf(" -----\n");
}
}
printf("\n");
}
int is_game_over(char board[3][3])
{
int is_draw=1;
int i,j;
for ( i = 0; i < 3; i++) {
if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != ' ') {
return 1;
}
if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[0][i] != ' ') {
return 1;
}
}
if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != ' ') {
return 1;
}
if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[0][2] != ' ') {
return 1;
}
for ( i = 0; i < 3; i++) {
for ( j = 0; j < 3; j++) {
if (board[i][j] == ' ') {
is_draw = 0;
break;
8
}
}
}
if (is_draw) {
return 2;
}
return 0;
}
void main()
{
char board[3][3];
int row, col, player = 1, game_status = 0;
clrscr();
initialize_board(board);
do
{
display_board(board);
if (player == 1) {
printf("Player X's turn\n");
}
else
{
printf("Player O's turn\n");
}
printf("Enter row (1, 2, or 3) and column (1, 2, or 3) separated by a space: ");
scanf("%d %d", &row, &col);
if(row < 1 || row > 3 || col < 1 || col > 3 || board[row - 1][col - 1] != ' ') {
printf("Invalid move! Try again.\n");
continue;
}
9
if (player == 1)
{
board[row - 1][col - 1] = 'X';
player = 2;
}
else
{
board[row - 1][col - 1] = 'O';
player = 1;
}
game_status = is_game_over(board);
}
while(game_status == 0);
display_board(board);
if(game_status == 1) {
printf("Player %c wins!\n", (player == 1) ? 'O' : 'X');
}
else
{
printf("It's a draw!\n");
}
getch();
}
● OUTPUT :-
10
11
● CONCLUSION :-
12
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 algorithmof playing Tic Tac Toe has been presented and tested that works in
efficient way. Overall thesystem works without any bugs .
● REFERENCE :-
https://www.academia.edu/36672411/_Tic_Tac_Toe_Game_Project
https://www.geeksforgeeks.org/tic-tac-toe-game-in-c/
https://www.researchgate.net/publication/316534681_Tic-Tac-Toe
13