Tic Tac Toe Report
Tic Tac Toe Report
TECHNOLOGY
ABSTRACT:
Our project name is Tic-Tac-Toe game. This game is very popular and is
fairly simple by itself. It is actually a two player game. In this game, there
is a board with n x n squares. In our game, it is 3 x 3 squares.
The goal of Tic-Tac-Toe is to be one of the players to get three same
symbols in a row - horizontally, vertically or diagonally - on a 3 x 3 grid.
Overview:
This game can be played in a 3x3 grid (shown in the figure 2.1) .The game
can be played by two players. There are two options for players:
For the option human, both the players are human and for the option
computer, the first player is human and the second player is
computer.
Theory of Game:
A player can choose between two symbols with his opponent, usual games
use “X”and “O”. If first player choose “X” then the second player have to
play with “O” and vice versa.
A player marks any of the 3x3 squares with his symbol (may be “X” or “O”)
and his aim is to create a straight line horizontally or vertically or diagonally
with two intensions:
In case logically no one can create a straight line with his own symbol, the
game results a tie.
Hence there are only three possible results – a player wins, his
opponent (human or computer) wins or it’s a tie.
The Tic Tac Toe game is a game for two players, called "X" and "O", who take
turns marking the spaces 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 time whether you're standing in a line or
spending time with your kids. Stop wasting paper and save trees. Because of the
simplicity of Tic Tac Toe, it is often used as a pedagogical tool for teaching the
concepts of good sportsmanship and the branch of artificial intelligence
OUTPUT
CODE:
#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;
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[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;
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
*******************************************************************
*/
void board()
{
system("cls");
printf("\n\n\tTic Tac Toe\n\n");
printf(" | | \n");
printf(" %c | %c | %c \n", square[1], square[2], square[3]);
printf("_____|_____|_____\n");
printf(" | | \n");
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" | | \n\n");
}
/*******************************************************************
END OF PROJECT
*******************************************************************
*/
Learning Outcomes:
After Making this project student will able to :
1) Use the Arrays
2) Concept of functions
References:
1) https://www.academia.edu/28164640/Project_Report_Tic_Tac_Toe
2) https://fdocuments.in/document/report-for-mini-projecttic-tac-toe-using-
c.html
3) https://www.codewithc.com/mini-project-in-c-tic-tac-toe-game/