Thread: Help with tic tac toe program

1. Help with tic tac toe program

Hey everyone... again I need a lot of help. I am to write a tic tac toe program and I'm not sure how to go about doing this. What i do know is that I want the num pad to be the board (it'll work nicely), but I dunno how to go about doing it.

"You are to make a two player version of tic-tac-toe, using a two-dimensional array as the board. Your program should not allow the players to cheat in anyway (ie erase a move that has already been done). ".

I need to use a 2d array... and nothing fancy. Just forloops, switches or if statements (switches preferebly)... no extra header files except maybe conio (to clear the screen whena new move is made im thinking...)

So if anyone could help me with an algorithm I would be very happy. I am clueless on how to make the turns and all taht. I am guessing functions, but they confuse me.

THANKS for even reading this people. I appreciate it very much

2. A high-level algorithm would look something like this:

Code:
```While Game Not Over
{
If Player 1's Turn
Player 1 Move

If Player 2's Turn
Player 2 Move

Update Board

If Game Is Over
Stop
}```

3. To get an idea of what to try, you could search the board for previous posts regarding "tic tak toe" or "naughts and crosses" or whatever. If you search hard enough you might even find a completed, functional program. However, the best idea is to think this through yourself, presuming you know how to play the game to begin with. You already know some stuff--eg, you need to use a 2D array to represent the board. If you aren't familiar with that concept start there. Ask yourself, "a 2D array of what?". How do I declare that? How do I initialize that? How do I alter that? How do I display that? Then when you can manipulate a 2D array of whatever, ask questions regarding the game itself, like how do I control who's move it is, what mark to make where, how to ask the user to chose a spot to make the mark, how to determine if the game is over, how to determine the outcome of the game, etc.? By breaking the project up into a group of smaller projects you can tackle one at a time, you're more likely to reach your goal.

4. hell, long time since i was away.

i got a solution -- one of my erly days -- it aint classical, of course, but it works nonetheless, with perhaps a few glitches in the computer play section. see the searchforwin( ) and didwin() functions. it might help.

Happy Hunting....
Psycho