hello,
I have to create a tictactoe game for my programming class. I have everything working execpt for my while loop to check to see if a space is already taken.
That was actually quite short, relative to what I've had to read more recently.
I have helped someone else map a grid to a 1-d array. Hopefully, this will work for you too.
There are nine spaces in a tic-tac-toe game. Every three spaces, there's a newline. You need an integer array of length nine. 0 for empty, 1 for X, 2 for O.
To convert between the co-ordinate system (the top left corner is (0,0)), then the forumla for what character on the linear array should be is (note that the array starts from zero) rownumber*3 + columnnumber;
EDIT: When checking, have the program retrieve that data in the section specified by that formula, and optionally write to that space as well.
This way, you don't need a while loop, and it's so much easier to manage the data.
thanks i appreciate the help but i'd really like to get the boolean working because the rest of the program works the way it should when i // out the section.