Here is my problem I'm supposed to write a tic-tac-toe game.By the way this is the biggest program I've ever attempted to write. When I started writing the game I thought that it wouldn't be too difficult to do-boy was I wrong. The specs for the game are that a human plays the computer (random number generator). The human player chooses to be X or O,X moves first. Right now all the game does is prompt the user to choose X or O. After that is done I can play as X or O only. I can fill the game board with X's or O's (run the code thus far to see what I'm talking about). This is what I need to add to the game.
As for Item one I think that I need to use two arrays to solve this problem:
One is the board[] array that is the actual game board and I think that the other array I need is a copy of the board[] array to store move choices. Lets say I name this array- full[]. The fulll[] array holds the actual move choices. I think that I need to continually search the full array (using a while loop) to find move choices and to prompt the user that they can't pick that spot. For example if the human player chooses number 5 and puts an X in there the computer can not put an O in the same place and the human player cant put another X in space 5. As for problem two I just need to write a function to call a random number generator. Someone point me in the right direction. I don't want anyone to do it for me,but I do need some help. Here is my code to this point:
- A way to store a previous move choice and not allow a move to be over written by a subsequent move
- A call to the random number generator to get the computer's move
As for Item one I think that I need to use two arrays to solve this problem:
One is the board[] array that is the actual game board and I think that the other array I need is a copy of the board[] array to store move choices. Lets say I name this array- full[]. The fulll[] array holds the actual move choices. I think that I need to continually search the full array (using a while loop) to find move choices and to prompt the user that they can't pick that spot. For example if the human player chooses number 5 and puts an X in there the computer can not put an O in the same place and the human player cant put another X in space 5. As for problem two I just need to write a function to call a random number generator. Someone point me in the right direction. I don't want anyone to do it for me,but I do need some help. Here is my code to this point:
Comment