answersLogoWhite

0


Best Answer

THE PROGRAM FOR TIC TAC TOE IN "C" LANGUAGE ARE:

#include <stdio.h>

#include <ctype.h>

#define String_Length 80

#define Squares 9

typedef char Square_Type;

typedef Square_Type Board_Type[Squares];

const Square_Type Empty = ' ';

const int Infinity = 10; /* Higher value than any score */

const int Maximum_Moves = Squares; /* Maximum moves in a game */

int Total_Nodes; /* Nodes searched with minimax */

/* Array describing the eight combinations of three squares in a row */

#define Possible_Wins 8

const int Three_in_a_Row[Possible_Wins][3] = {

{ 0, 1, 2 },

{ 3, 4, 5 },

{ 6, 7, 8 },

{ 0, 3, 6 },

{ 1, 4, 7 },

{ 2, 5, 8 },

{ 0, 4, 8 },

{ 2, 4, 6 }

};

/* Array used in heuristic formula for each move. */

const int Heuristic_Array[4][4] = {

{ 0, -10, -100, -1000 },

{ 10, 0, 0, 0 },

{ 100, 0, 0, 0 },

{ 1000, 0, 0, 0 }

};

/* Structure to hold a move and its heuristic */

typedef struct {

int Square;

int Heuristic;

} Move_Heuristic_Type;

/* Clear the board */

void Initialize(Board_Type Board) {

int I;

for (I = 0; I < Squares; I++)

Board[I] = Empty;

}

/* If a player has won, return the winner. If the game is a tie,

return 'C' (for cat). If the game is not over, return Empty. */

Square_Type Winner(Board_Type Board) {

int I;

for (I = 0; I < Possible_Wins; I++) {

Square_Type Possible_Winner = Board[Three_in_a_Row[I][0]];

if (Possible_Winner != Empty &&

Possible_Winner 'Y');

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program for tic tac toe in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Apply Algorithm minimax with alpha-beta cut-offs with limited depth to the game tic-tac-toe?

Check out this nice tutorial article on how to apply alpha-beta pruning in Objective C, for a turn based game just like tic-tac-toe... http://www.imapps.net/devblog/files/alphabeta-objc.html


Why in tic-tac-toe when there is a tie it's called a Cat's game?

Tic Tac Toe ties are called cats game because no matter how hard a cat tries to win against its tale it never wins and yet has fun.Another reason I believe in is The reason it is called a Cat's game is that usually when the game ends in a tie it will make a letter "c" in the game board.


What is c-tack?

What you think is c-tack is most likely spelled Sea-tac. Sea-tac is an airport in the Seattle region. I am notexactly sure of its location but close enough.


I want to ask especially to experienced programmer I'm learning C and Python now But I want to learn further breaking the plateau Please give me advice to get advanced Thank you?

If you want to learn more about your specific programming language, I would recommend making a small game of sorts. It will test everything you know how to do in your language and is a fun learning experience. The game you make doesn't need to be some fancy FPS with 3D graphics, it can be a TIC-TAC-TOE game with a simple GUI and AI.


What does t.i. c. mean in tic federal credit union?

TIC is near Fort Benning which used to be called The Infantry Center. Though it's not called that any more, TIC kept the name.


What are some small words ending in the letter c?

tic logic


What is the complementary DNA for TAC GG?

The complementary DNA sequence for TAC GG is ATG CC. This is because in DNA, adenine pairs with thymine and cytosine pairs with guanine.


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.


Features of c program?

the features of a C program


What is executive a c program?

I think it is 'execution of a C program'.


C program on left factoring in compiler design?

how to create a c program for left factoring.


How much percentage of Ti and C in 5 gr of TiC?

THere are 4 grams of Ti and 1 gram of C(oochie). Making 5 grams of Ti(ght) C(coochie).