tic-tac-toe problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • triphoppa
    New Member
    • Oct 2008
    • 16

    tic-tac-toe problems

    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.
    • 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:
  • curiously enough
    New Member
    • Aug 2008
    • 79

    #2
    What parts exactly of the code you want to write are you confused about?

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Originally posted by triphoppa
      • 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
      I have removed your code, we do not allow posting of full code to class assignments (this prevents your lectures accusing you of copying from this site). Also I do not think it is required to answer your questions.

      As to storing the move choice and board what you suggest is possible but sounds over complicated, the whole thing can be done with a single array.

      Generating random numbers is not hard, look up the function rand in you C text books (or google it).

      Comment

      • curiously enough
        New Member
        • Aug 2008
        • 79

        #4
        Originally posted by Banfa
        I have removed your code, we do not allow posting of full code to class assignments (this prevents your lectures accusing you of copying from this site). Also I do not think it is required to answer your questions.

        As to storing the move choice and board what you suggest is possible but sounds over complicated, the whole thing can be done with a single array.

        Generating random numbers is not hard, look up the function rand in you C text books (or google it).
        If we can't see his full code then how are we supposed to know where he went wrong?

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Originally posted by curiously enough
          If we can't see his full code then how are we supposed to know where he went wrong?
          The OP has asked 2 questions, 1 is easily answerable from the C standard library.

          The other is theoretical and the OP has provided his thinking on that. You can then provide guidance in theory using non-complete examples if required on the methods they are thinking of using without need to recourse to the OPs actual code.

          The theory is where the program design and the understanding of the working of computers is, the code is merely a syntactical representation of that understanding.

          Comment

          • curiously enough
            New Member
            • Aug 2008
            • 79

            #6
            Originally posted by Banfa
            The OP has asked 2 questions, 1 is easily answerable from the C standard library.

            The other is theoretical and the OP has provided his thinking on that. You can then provide guidance in theory using non-complete examples if required on the methods they are thinking of using without need to recourse to the OPs actual code.

            The theory is where the program design and the understanding of the working of computers is, the code is merely a syntactical representation of that understanding.
            I understand why I am not allowed to post a full code, but why can't he post it with his question? The reason that was given for this in the posting guidelines was very silly.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Originally posted by curiously enough
              I understand why I am not allowed to post a full code, but why can't he post it with his question? The reason that was given for this in the posting guidelines was very silly.
              curiously enough, the guidelines are there and have been carefully thought through.

              It is a requirement that you follow them, if you believe them to be wrong please feel free to post the part of the guidelines you do not agree with along with your reasoning for their being incorrect in the "Feedback, bugs and suggestions" forum.

              Please do not hijack this thread any further with this off topic discussion.

              Comment

              • triphoppa
                New Member
                • Oct 2008
                • 16

                #8
                This "resource" is free to use,however the over simplistic catch all rules is running me away. My code was not complete-even if it was how in the world can someone see what is wrong when they can't see the code? I'm not going to complain anymore,but I also doubt that I'll frequent this board again. If you want a useful community I think some attitudes around here need to change.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32656

                  #9
                  It seems everyone is missing the point today.

                  For a fuller (not to say exhaustive) explanation of why the rules are like this (if you look at the rule itself it's explained in pretty fine detail anyway) check out Posting full code.

                  If you still can't understand, then I see no benefit in further explanation.

                  Comment

                  Working...