I love gaming and its one of the reasons I got interested in coding and I am currently working on this tic tac toe game and I would love if you guys could help me out with a game I am working with and help me make these 5 improvements, thank you so much :)
1.Determine when a player has won with "3 in a row" ( horz., vert., or diagonal).
2.Determine who wins( has the most boxes) when all 9 boxes have been filled.
3.Do not allow a state to be repeated during the playing of a game.
4.Do not allow a box (1-9) to be selected more than once during the playing of a game.
5.Allow any case of letters typed by the player to match the answer.
// function prototypes
void loadst(string[], string[]);
void play(string[], string[]);
void drawsq(void);
int pickst(void);
int main()
{
string states[50], caps[50];
char choice = 'y';
srand(time(NULL)); /* seed the random number sequence */
loadst(states, caps); /* get input data*/
system("cls");
while (tolower(choice) == 'y')
{
drawsq();
play(states, caps);
COORD coord = {1, 20};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
cout << "DO YOU WANT TO PLAY AGAIN? (Y/N) ";
cin >> choice;
}
}
/**************************** DRAW SQUARE FUNCTION */
void drawsq(void)
{
string board[9] = {
"1 |2 |3 ",
" | | ",
"---+---+---",
"4 |5 |6 ",
" | | ",
"---+---+---",
"7 |8 |9 ",
" | | "
};
int i, x, y;
system("cls");
y = 0;
x = 40;
for (i = 0; i < 9; i++)
{
y++;
COORD coord = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
cout << board[i];
}
}
/***************************** PICK RANDOM STATE */
int pickst()
{
return (rand() % 50);
}
/**************************** LOAD STATES FUNCTION */
void loadst(string states[], string caps[])
{
ifstream infile;
string temp;
coord.X = 1;
coord.Y = 18;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
cout << "THE CAPITAL OF " << states[stpick] << " IS ? ";
getline(cin, answer);
for (i = answer.length(); i < 14; i++)
answer.append(" ");
The exact same thing you asked on stackoverflow. It's better to ask it here, even if there is less people. Stackoverflow is strict, when you asked three questions that got voted down, you get a question ban, until you give enough positive energy to the community. I got into a question ban, and I had to swich accounts. My name is Bob the zealot by the way. Nice to meet you!