Help with tic tac toe program

This is a discussion on Help with tic tac toe program within the C++ Programming forums, part of the General Programming Boards category; Hey everyone... again I need a lot of help. I am to write a tic tac toe program and I'm ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    16

    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. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    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. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    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. #4
    Registered User kiss_psycho's Avatar
    Join Date
    Feb 2003
    Posts
    49
    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
    Attached Files Attached Files
    Definition of Programmer : A red-eyed mumbling mammal capable of conversing with inanimate objects.

    Happy Hunting...
    The Root

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe!
    By Sinensis in forum C Programming
    Replies: 2
    Last Post: 10-21-2008, 04:40 PM
  2. Check tic tac toe winner
    By cjmdjm in forum C++ Programming
    Replies: 3
    Last Post: 11-04-2005, 11:41 AM
  3. tic tac toe
    By holden in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 05-09-2004, 09:59 AM
  4. My First c++ program : TIC TAC TOE !
    By renderstream in forum C++ Programming
    Replies: 7
    Last Post: 03-07-2004, 03:58 PM
  5. Need help with Tic Tac Toe
    By Zerostatic in forum C++ Programming
    Replies: 19
    Last Post: 07-19-2002, 07:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21