improving my tic tac toe game

Im trying to twist this tic tac toe I made , I want to make it in to 5x5 grid or 6x6 grid , but the rules are quite different , if player one forms a straigh "XXX" on the grid , the player scores , but the game continues until all the boxes are occupied . In short , the many straight XXX or OOO you have , the more points you will earn. CAN anyone give suggestions/ideas where to start or to change ?

PS : NEVERMIND THE COMMENTS its our native language :)


#include<iostream>
using namespace std;
#include<stdlib.h>
//ANG LIBRARY NA STDLIB.H EH PINAPAGANA UNG SYSTEM("CLS")
// ANG SYSTEM("CLS") EH PANGCLEAR SCREEN

//TAWAG DITO MGA FUNCTION HEADER. NOT SURE. LOLZ
void gamePlay();
void resetGame();
void playerOne();
void playerTwo();
void ticTac();
void ticTacEx();
void ticTacExOne();
void tryAgain();
void howtoPlay();
void contGame();
void contGameEx();
void displayScreen();
int gameWin(int& check);
char array[]={'1','2','3','4','5','6','7','8','9'};


int main() //MAIN FUNTION NATIN TOH.
{
displayScreen(); //TINATAWAG NI MAIN SI DISPLAYSCREEN
return 0;
}

void gamePlay() //PAPASOK SI DISPLAYSCREEN DITO PAG '1' ANG ININPUT NG USER
{
int check, plyrA=0, plyrB=0, numGames, sum=0, again=0;
cout<<"\t\t\t Number Of Games You Want: ";
//MAY MALI DITO D KO MAGAWAN NG PARAAN.
cin>>numGames;
system("cls");

if (numGames<=0)
{
cout<<"\t\t\t\t Invalid Input"<<endl;
gamePlay();
}

system("cls");

ticTac(); //TATAWAGIN NI GAMEPLAY SI TICTAC


//BABALIK DITO SI TICTAC PAGKATAPOS MAPRINT YUNG BOX
while(sum!=numGames)
{
int ctr=0;
int tie=0;
//BAKIT YUNG TIE EH 9? KASI LAST MOVE YUN
//KASI DIBA PAG LAST MOVE NA SA TICTACTOE AUTOMATIC TIE NA SILA
while(ctr!=1 && tie!=9)
{
playerOne();//TATAWAGIN NI GAMEPLAY SI PLAYERONE
ctr=gameWin(check); //PUPUNTA SIYA KAY GAMEWIN(CHECK) AT MALALAGAY KAY CTR
//KAPAG YUNG CONDITION KAY GAMEWIN EH MAY TUMAMA,
//PAPASOK SIYA DITO SA IF STATEMENT NA UNA
if (ctr==1)
{
system("cls");
cout<<endl;
cout<<"\t\t\t\tPlayer One Wins The Game!"<<endl<<endl;
plyrA++;
//ETO UNG CONDITION PAG NANALO YUNG PLAYER
//PARANG NUMBRE OF WINS TOH
resetGame();
//ITONG RESETGAME EH PAG MAY NANALO LANG
//BALE MAALIS YUNG LETTER X OR LEETER O
//BABALIK ULIT SA MGA CHOICES NA NUMBERS
ticTac();
continue;
}
tie++;
//KAPAG UMABOT SILA NG HANGGANG 9 MOVES, EDI TIE SILA. LOLZ
if(tie==9)
{
system("cls");
cout<<endl;
cout<<"\t\t\t\t\tA Tie!"<<endl;
resetGame();
ticTac();
continue;
}

playerTwo(); //PAREHO LANG KAY PLAYER ONE
ctr=gameWin(check);

if (ctr==1)
{
system("cls");
cout<<endl;
cout<<" Player Two Wins The Game!"<<endl<<endl;
plyrB++; //PAREHO LANG KAY PLAYERONE
resetGame(); //PAREHO LANG KAY PLAYERONE
ticTac();
continue;
}
tie++;
//PAREHO LANG DIN KAY PLAYER ONE BASAHIN NIYO NA LANG
if(tie==9)
{
system("cls");
cout<<endl;
cout<<"\t\t\t\t\tA Tie!"<<endl;
resetGame();
ticTac();
continue;
}

}
//YUNG SUM++ NA TOH PARA DUN SA CONDITION STATEMENT
//DIBA SUM=0, TAPOS PAG ANG ININPUT NG USER EH 2GAMES
//MAUULIT ITONG PROGRAM NG DALAWANG BESES
//ANG PURPOSE NG SUM++ PARA D MAGTULOY-TULOY ANG LARO
sum++;

}
//PAG TAPOS NA YUNG GAME, ITO NA ANG MADIDISPLAY
cout<<endl;
cout<<"\t\t ========================================="<<endl;
cout<<"\t\t TOTAL SCORE"<<endl;
cout<<"\t\t WINS"<<endl;
cout<<"\t\t Player One: "<<plyrA<<endl;
cout<<"\t\t Player Two: "<<plyrB<<endl;
cout<<endl;
tryAgain(); //TATAWAGIN NI GAMEPLAY SI TRYAGAIN KUNG GUSTO PA O HINDI NA



}


void resetGame() //DITO PAPASOK SI GAMEPLAY PAG MAY NANALO
{

int b='1';

for(int a=0; a<9;a++)
{
array[a]=b;
//ETO ANG MAGIGING RESULT. MALALAGAY YUNG VALUE NA YAN SA MGA ARRAYS
//ARRAY[0]='1' ARRAY[1]='2' ARRAY[2]='3'
//ARRAR[3]='4' ARRAY[4]='5' ARRAY[5]='6'
//ARRAY[6]='7' ARRAY[7]='8' ARRAY[8]='9'
//YAN ULIT ANG MADIDISPLAY KASI NARESET YUNG GAME
b++;

}

}


int gameWin(int& check) //TINAWAG TO NI GAMEPLAY
//ANG PURPOSE NITO EH MACHECK KUNG MAY TATLONG NAKABUO NA NG PATTERN
{
if(array[0] == array[1] && array[2] == array[0])
//EXAMPLE
//KUNG SI ARRAY[0]=X == ARRAY[1]==X && ARRAY[2]=X ==ARRAY[0]=X
//PAG PAREPAREHO SILANG X OR O
// 0 1 2 YAN YUNG MGA ARRAY X X X
// 3 4 5 MAGIGING GANITO SIYA SA 3 4 5
// 6 7 8 CONDITION NA TO ----> 6 7 8
{
check=1;
return check;
}

else if(array[3] == array[4] && array[5] == array[3])
// 0 1 2 YAN YUNG MGA ARRAY 0 1 2
// 3 4 5 MAGIGING GANITO SIYA SA X X X
// 6 7 8 CONDITION NA TO ----> 6 7 8
{
check=1;
return check;
}

else if(array[6] == array[7] && array[8] == array[6])
// 0 1 2 YAN YUNG MGA ARRAY 0 1 2
// 3 4 5 MAGIGING GANITO SIYA SA 3 4 5
// 6 7 8 CONDITION NA TO ----> X X X
{
check=1;
return check;
}

else if(array[0] == array[3] && array[6] == array[0])
// 0 1 2 YAN YUNG MGA ARRAY X 1 2
// 3 4 5 MAGIGING GANITO SIYA SA X 4 5
// 6 7 8 CONDITION NA TO ----> X 7 8
{
check=1;
return check;
}

else if(array[1] == array[4] && array[7] == array[1])
// 0 1 2 YAN YUNG MGA ARRAY 0 X 2
// 3 4 5 MAGIGING GANITO SIYA SA 3 X 5
// 6 7 8 CONDITION NA TO ----> 6 X 8
{
check=1;
return check;
}

else if(array[2] == array[5] && array[8] == array[2])
// 0 1 2 YAN YUNG MGA ARRAY 0 1 X
// 3 4 5 MAGIGING GANITO SIYA SA 3 4 X
// 6 7 8 CONDITION NA TO ----> 6 7 X
{
check=1;
return check;
}

else if(array[0] == array[4] && array[8] == array[0])
// 0 1 2 YAN YUNG MGA ARRAY X 1 2
// 3 4 5 MAGIGING GANITO SIYA SA 3 X 5
// 6 7 8 CONDITION NA TO ----> 6 7 X
{
check=1;
return check;
}

else if(array[2] == array[4] && array[6] == array[2])
// 0 1 2 YAN YUNG MGA ARRAY 0 1 X
// 3 4 5 MAGIGING GANITO SIYA SA 3 X 5
// 6 7 8 CONDITION NA TO ----> X 7 8
{
check=1;
return check;
}
//ETO NAMAN ANG MANGYAYARI PAG WALA PANG PATTERN
//ANG CHECK=0 PA RIN
else
{
check=0;
return check;
}


}


void displayScreen() //BALE DITO MAPUPUNTA SI MAIN
{
char choose;
//ETO YUNG MADIDISPLAY SA SCREEN
cout<<endl;
cout<<" [1] Start The Game"<<endl;
cout<<endl;
cout<<" [2] How To Play The Game"<<endl;
cout<<endl;
cout<<" [3] Exit"<<endl;
cout<<endl;
cout<<endl;

cout<<"\t\t\tEnter A Number In The Menu That You Want: ";
cin>>choose;
system("cls");

switch(choose)
{
case '1':
gamePlay(); //PUPUNTA SIYA KAY GAMEPLAY
break;

case '2':
howtoPlay(); //PUPUNTA SIYA KAY HOWTOPLAY
break;


case '3':
cout<<"\t\t\t Thank You For Using Our Program"<<endl<<endl;
break;

default:
cout<<"\t\t\t\tInvalid Input"<<endl;
tryAgain();
break;
}
}


CONTINUATION..next comment
void howtoPlay() //DITO MAPUPUNTA SI DISPLAYSCREEN PAG 2 ANG PINILI NG USER
{
cout<<"\t\tThis Is A Simple Program Made In C++ Called TicTacToe"<<endl;
cout<<"\t\t\tThis Is A Sample Preview Of The Program"<<endl<<endl;
resetGame(); //NILAGAY KO TOH KASI BAKA MAGLARO MUNA SILA BAGO TIGNAN ANG HOWTOPLAY
ticTac(); //TAPOS IPRIPRINT NIYA SI TICTAC
contGameEx(); //PUPUNTA SI HOWTOPLAY KAY CONTGAMEEX
cout<<"\t\tThe Player One Will Be The One To Choose A Number In The Box"<<endl;
cout<<"\t\tThe Player One's Legend is 'X' and Player Two's Legend Is 'O'"<<endl;
cout<<"\t\tThis Is A Sample Output If Player One Choose Box 1 and"<<endl;
cout<<"\t\t\t Player Two Choose Box 5"<<endl<<endl;
resetGame(); //PAREHO LANG SA UNA
ticTacEx(); //IDIDISPLAY NIYA YUNG SAMPLE FIGURE NG BOX
contGameEx(); //PAREHO LANG SA UNA
cout<<"\t\tA Player Wins If He/She Get A Three Legend In Straight Line"<<endl;
cout<<"\t\tor Diagonal Line"<<endl<<endl;
cout<<"\t\tThis Is A Sample Of A Player's Move Who Wins The Game"<<endl<<endl;
ticTacExOne(); //PUPUNTA SIYA KAY TICTACEXONE NAMAN
contGame(); //PUPUNTA SIYA KAY CONTGAME
}


void contGame() //TINAWAG NI HOWTOPLAY
{
char cont;
cout<<endl;
cout<<"\t\t\tDo You Want To Proceed To The Game [y/n]: ";
cin>>cont;
//KAPAG Y, PUNTA NA SIYA AGAD KAY GAMEPLAY
if(cont=='y' || cont=='Y')
{
system("cls");
gamePlay();
}
//PAG N NAMAN, BABALIK SIYA KAY MAIN
else if(cont=='n' || cont=='N')
{
system("cls");
main();
}
//PAG WALA NAMAN, INVALID ANG INPUT
else
{
cout<<"\t\t\t\t Invalid Input"<<endl;
contGame(); //BABALIK LANG SIYA KAY CONTGAME
}
}

void contGameEx() //ETO ANG CONDITION PAG GUSTO NG PLAYER NA ITULOY BASAHIN
{
char cont;
cout<<endl;
cout<<"\t\t\t Do You Want Read More? [y/n]: ";
cin>>cont;
//ETO CONDITION
//PAG Y, CLEARSCREEN SIYA TAPOS BABALIK KAY HOWTOPLAY KASI SIYA TUMAWAG
if(cont=='y' || cont=='Y')
{
system("cls");
}
//PAG N NAMAN, BABALIK SIYA KAY MAIN KASI AYAW NA NIYA BASAHIIN
else if(cont=='n' || cont=='N')
{
system("cls");
main();
}
//PAG INVALID NAMAN, BABALIK LANG SIYA KAY CONTGAMEEX
else
{
cout<<"\t\t\t\t Invalid Input"<<endl;
contGameEx();
}
}

void tryAgain()
{
char tryA;
cout<<"\t\tInput letter m if you want to go back to main menu"<<endl;
cout<<"\t\t\t Do You Want Try Again?[y/n]: ";
cin>>tryA;
if(tryA=='y' || tryA=='Y')
{
system("cls"); //CLEAR SCREEN
resetGame();
gamePlay(); //TATAWAGIN NIYA SI GAMEPLAY
}
else if(tryA=='n' || tryA=='N')
{
system("cls");
cout<<"\t\t That Was A Great Game! Thanks For Playing"<<endl<<endl;
}
else if (tryA=='m' || tryA=='M')
{
system("cls");
main();// PUPUNTA SIYA KAY MAIN
}
else
{
cout<<"\t\t\t\t Invalid Input"<<endl;
tryAgain();//BABALIK SIYA KAY TRYAGAIN
}
}

void ticTac() //DITO PAPASOK SI GAMEPLAY
{
//MAPRIPRINT TONG DRAWING O BOX
//YAN ANG MAGIGING PARANG BOARD NILA
//BABALIK ULIT SI TICTAC KAY GAMEPLAY KASI SIYA TUMAWAG
//PAPASOK DIN DITO SI PLAYERONE AT PLAYERTWO PARA MADISPLAY YUNG BAGONG BOX KAPAG NAKAPILI SILA
cout<<endl<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[0]<<" | "<<array[1]<<" | "<<array[2]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[3]<<" | "<<array[4]<<" | "<<array[5]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[6]<<" | "<<array[7]<<" | "<<array[8]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<endl;

}

void ticTacEx() //TATAWAGIN SIYA N HOWTOPLAY
{

//IDIDISPLAY NIYA YUNG SAMPLE OUTPUT MAY NAINPUT
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<"X"<<" | "<<array[1]<<" | "<<array[2]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[3]<<" | "<<"O"<<" | "<<array[5]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[6]<<" | "<<array[7]<<" | "<<array[8]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<endl;
//BABALIK SIYA KAY HOWTOPLAY KASI SIYA TUMAWAG KAY TICTACEX

}

void ticTacExOne() //TINAWAG NI HOWTOPLAY
{

//SAMPLE OUTPUT NAMAN NG PANALO TAPOS BABALIK ULIT KAY HOWTOPLAY
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<"X"<<" | "<<array[1]<<" | "<<array[2]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[3]<<" | "<<"X"<<" | "<<array[5]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[6]<<" | "<<array[7]<<" | "<<"X"<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========|"<<endl;
cout<<endl;

}


continuation......
void playerOne() //DITO MAPUPUNTA SI GAMEPLAY
{
char boxOne;
int ctr=0;
while(ctr!=1)
{
cout<<"\t\t\t\t Player One: "<<endl;
cout<<"\t\t\t Choose A Number In The Box: ";

cin>>boxOne;
//BALE PIPILI NG BOX SI PLAYERONE
//YAN YUNG CONDITIONS KAPAG MERON O WALA PANG NALAGYAN SA BOX NA PINILI
switch(boxOne)
{
case '1':
if (array[0] == 'X' || array[0] =='O')
cout<<endl<<"\t\tThe Box [1] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[0]='X';
ctr++;
}
break;

case '2':
if (array[1] == 'X' || array[1] =='O')
cout<<endl<<"\t\tThe Box [2] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[1]='X';
ctr++;
}
break;

case '3':
if (array[2] == 'X' || array[2] == 'O')
cout<<endl<<"\t\tThe Box [3] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[2]='X';
ctr++;
}
break;

case '4':
if (array[3] == 'X' || array[3] == 'O')
cout<<endl<<"\t\tThe Box [4] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[3]='X';
ctr++;
}
break;

case '5':
if (array[4] == 'X' || array[4] == 'O')
cout<<endl<<"\t\tThe Box [5] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[4]='X';
ctr++;
}
break;

case '6':
if (array[5] == 'X' || array[5] == 'O')
cout<<endl<<"\t\tThe Box [6] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[5]='X';
ctr++;
}
break;

case '7':
if (array[6] == 'X' || array[6] == 'O')
cout<<endl<<"\t\tThe Box [7] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[6]='X';
ctr++;
}
break;

case '8':
if (array[7] == 'X' || array[7] =='O')
cout<<endl<<"\t\tThe Box [8] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[7]='X';
ctr++;
}
break;

case '9':
if (array[8] == 'X' || array[8] =='O')
cout<<endl<<"\t\tThe Box [9] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[8]='X';
ctr++;
}
break;
//KAPAG WALA NAMAN SA CHOCES, DITO SIYA MAPUPUNTA
default:
cout<<endl<<"\t\t\tInvalid Input. Please Enter A Valid Number"<<endl<<endl;
break;
}

}
system("cls"); //PAGKATAPOS CLEARSCREEN NA SIYA
ticTac(); //TATAWAGIN NIYA SI TICTAC PARA MADISPLAY YUNG BAGONG IMAGE NG BOX KASI MAY NAPILI NA

}



void playerTwo()
{
char boxTwo;
int ctr=0;
while(ctr!=1)
{
cout<<"\t\t\t\t Player Two: "<<endl;
cout<<"\t\t\t Choose A Number In The Box: ";

cin>>boxTwo;
//PAREHO LANG TOH KAY PLAYERONE PERO LETTER O NAMAN KAY PLAYERTWO
//KAY PLAYER ONE KASI LETTER X
switch(boxTwo)
{
case '1':
if (array[0] == 'X' || array[0] =='O')
cout<<endl<<"\t\tThe Box [1] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[0]='O';
ctr++;
}
break;

case '2':
if (array[1] == 'X' || array[1] =='O')
cout<<endl<<"\t\tThe Box [2] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[1]='O';
ctr++;
}
break;

case '3':
if (array[2] == 'X' || array[2] == 'O')
cout<<endl<<"\t\tThe Box [3] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[2]='O';
ctr++;
}
break;

case '4':
if (array[3] == 'X' || array[3] == 'O')
cout<<endl<<"\t\tThe Box [4] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[3]='O';
ctr++;
}
break;

case '5':
if (array[4] == 'X' || array[4] == 'O')
cout<<endl<<"\t\tThe Box [5] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[4]='O';
ctr++;
}
break;

case '6':
if (array[5] == 'X' || array[5] == 'O')
cout<<endl<<"\t\tThe Box [6] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[5]='O';
ctr++;
}
break;

case '7':
if (array[6] == 'X' || array[6] == 'O')
cout<<endl<<"\t\tThe Box [7] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[6]='O';
ctr++;
}
break;

case '8':
if (array[7] == 'X' || array[7] =='O')
cout<<endl<<"\t\tThe Box [8] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[7]='O';
ctr++;
}
break;

case '9':
if (array[8] == 'X' || array[8] =='O')
cout<<endl<<"\t\tThe Box [9] Has Been Chosen. Choose Valid Number In The Box"<<endl<<endl;
else
{
array[8]='O';
ctr++;
}
break;
//GANUN DIN GAYA KAY PLAYER ONE
default:
cout<<endl<<"\t\t\tInvalid Input. Please Enter A Valid Number"<<endl<<endl;
break;
}

}
system("cls");
ticTac(); //PAPASOK DIN SIYA KAY TICTAC PARA MADISPLAY YUNG BAGONG BOX


}
where to start? use [ code] tags when you are posting sections of code on the forum.

oh and don't attack the problem until you understand it.
Topic archived. No new replies allowed.