/* WHEN PLAYER SELECT ANY NO THEN HIS WINING CHANGES ARE MORE IN IT's ADJACENCY LIST HENCE CHECK PLAYERS WINING CONDITION IN THE SAME LIST here let list plyar select no 7 then :- we have 7's list 5,3,4,1,8,9 so camper flag[5] & flag[3] with 1 if they are equle then player win else select next two no 4 & 1 and so on

/* IF PLAYER HAS VISITED BLOCK1 THEN TO BREAK HIS PATH PUT COMP's NO ON BLOCK2 AND VISE VARSA */if(flag[block1]==1 && flag[block2]==0){ compNo = block2;}if(flag[block2]==1 && flag[block1]==0){ compNo = block1;}}

if(pwin==1)//IF PLAREY WIN THEN BREAKbreak;

/* AS 5 IS CENTRAL BLOCK AND MAX. PAYTH ARE GOING THROUE IT SO IF PLARER HAS NOT VISITED IT THEN VISIT IT FIRST */if(flag[5]==0){ printcomp(5); flag[5] = 2;}else{//CHEACK FOR COMP WIN

cwin = compwin(GRAPH,flag);

if(cwin == 1)//IF COMP WIN THEN BREAKbreak;

/* IF PLAYER & COMP ARE NOT IN A POSITION TO WIN THE GAME THEN COMP HAS TO PLAY ANY NON VISITED BLOCK */if(compNo==0){while(ptr){if(flag[ptr->blockNo] == 0){ compNo = ptr->blockNo;break;} ptr = ptr->next;}}

/* WHEN PLAYER SELECT ANY NO THEN HIS WINING CHANGES ARE MORE IN IT's ADJACENCY LIST HENCE CHECK PLAYERS WINING CONDITION IN THE SAME LIST here: let list plyar select no 7 then :- we have 7's list 5,3,4,1,8,9 so camper flag[5] & flag[3] with 1 if they are equle then player win else select next two no 4 & 1 and so on

cout<<"\n\n\nThe rules of the game are as follows:-\n\n" <<"Press the number indicated near the playing box \n" <<"to put the symbol \" X \" in the playing box.\n" <<"\nDo not press a number in which a symbol such as\n" <<"\"'X' or 'O'\" already exist. If you do so the\n" <<"program will give error due to illegal inputs\n" <<"\nYour aim is to get a line containing 3 'X'\n" <<"either horizontally or vertically or diagonally\n" <<"with alternative inputs by you and computer\n"; settextstyle(5 , HORIZ_DIR, 2); outtextxy(100,430,"press any key to continue..........."); getch();}/*************************************************************void help() to show the help for the Game

void help(void){ cout<<"\n\nAs the rule of the Game get a line containing 3 'X'\n" <<"either hrizontally or vertically or diagonally\n" <<"with alternative inputs by you and computer.\n" <<"\nAlways try to occupy the middle box and\n" <<"then the corners for confusing the computer\n"; settextstyle(5 , HORIZ_DIR, 2); outtextxy(100,310,"Press any key to continue.........."); getch();}

//end of program

Related Articles

Good stuff. Why not post it as an article instead, with code commenting and explaining how you did the design and implementation? This would be of interest to beginner programmers, I'm sure, as it is good to see how a program is built up from scratch.

Good stuff. Why not post it as an article instead, with code commenting and explaining how you did the design and implementation? This would be of interest to beginner programmers, I'm sure, as it is good to see how a program is built up from scratch.

actually i view the tic tac to game table as a graph, where each block is a vertex of a graph and the all possible paths are connected to it
ex: there is edge between 1 to 9 , 1 to 5 , 1 to 3, 1 to 2 , 1 to 7 , 1 to 4 etc.