Tic Tac Toe...Help getting started!

This is a discussion on Tic Tac Toe...Help getting started! within the C++ Programming forums, part of the General Programming Boards category; Hey guys, I'm still in the beginning stages of learning C++ and my newest assignment is to write a two ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    22

    Unhappy Tic Tac Toe...Help getting started!

    Hey guys, I'm still in the beginning stages of learning C++ and my newest assignment is to write a two player tic tac toe game. I am not asking you to write the program for me, I would just like you help me get started. Kind of like an outline for the program. What kind and how many functions should I be using?

    Here's my assignment requirements: http://www.cs.uwm.edu/classes/cs201/.../06/06/06.html

    Thanks so much!

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    I'd probably use at least these functions:
    main() -- obvious
    initializeBoard() -- set up the board to an empty state
    displayBoard() -- output the current state of the board
    acceptMove() -- input the position to mark
    testForWin() -- check the board to see if there was a win

    Basic outline:
    Code:
    Initilaize the board
    Start a loop
        display the board
        input a position to mark
        mark the position entered
        test for a win
        if a win, break out of loop
        set up for the next player
    end of loop
    display the board
    display the outcome
    More concepts must be added.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    I can remember creating a noughts and crosses game using Pascal during my A-levels (a long time ago ). There are alot of ways to approach the problem, but my solution took advantage of the fact that you can arrange the numbers 1-9 on a 3x3 board to create the sum of 15 in all directions.
    Code:
     2   9   4
     7   5   3
     6   1   8
    I'm pretty certain there are better ways than this in C++. Using this method, you have to check that the sum to 15 is made up of 3 numbers, no more or less (eg, 9+6 or 1+2+8+4)

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    I'm terrible at programming right now....can some one please give me some more insight on getting started. I don't even know where to begin. I have a lot of trouble with the structure but I can handle the details in between!

    Please help me out!

    Once again, I'm not asking you to do the assignment for me, but I would love it if some one could please give me a basic walkthrough or suggestions, as I'm having a lot of trouble in this course!

    Thanks so much!

  5. #5
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    I would say you need to be comfortable using/creating functions, using arrays, using loops, and conditional statements before you take this on.

    EDIT: (would arrays be the best way to store the board/the board data?)
    Oh my goodness.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    > please give me a basic walkthrough or suggestions,
    You're just being lame man, that page you posted is knee-deep in suggestions if you'd just go and actually read the damn thing. WaltP pretty much gave you the answer without actually posting the solution.

    This is program #12, what on earth did you do for programs 1 to 11?
    I assume you made at least some effort to solve them yourself, or did you wander from board to board whining on about how hard they were as well. If you did, then you've already failed and helping you is pointless.

    I mean, at least make some effort - how hard can it be to draw
    Code:
     | | 
    ------
     | | 
    ------
     | |
    Or just print
    Code:
    Welcome to Tic-Tac-Toe! 
    Three in a row wins!
    
    	1).Play a game
    	2).Quit
    
    Please make a selection:
    > as I'm having a lot of trouble in this course!
    Perhaps it's time to consider a change of course then, because this seems pretty spoon-feedy for a 6th assignment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    22
    Thanks for being a total douche about it Salem...I'm sure you picked up everything right away while learning C++ as well. I came here for help, not for someone (especially with that high of a post count) to sit here and flame my post. How am I to complete an assignment when I do not know where to begin?

    Anyway, thanks everyone for your suggestions.

    One question, I do not understand how to incorporate positions on board into the array? (We just got a brief run-down on arrays, so I am still a bit confused).

  8. #8
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by the_lumin8or
    Thanks for being a total douche about it Salem...I'm sure you picked up everything right away while learning C++ as well. I came here for help, not for someone (especially with that high of a post count) to sit here and flame my post. How am I to complete an assignment when I do not know where to begin?

    Anyway, thanks everyone for your suggestions.

    One question, I do not understand how to incorporate positions on board into the array? (We just got a brief run-down on arrays, so I am still a bit confused).
    Advice: When a God speaketh, ye should listen.
    EDIT: Maybe that should've been shall, not should. Meh.
    Last edited by cboard_member; 04-01-2006 at 03:32 AM.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    > I am not asking you to write the program for me
    Get off your ........ing arse then and start demonstrating that you can do something about it then.

    > not for someone (especially with that high of a post count) to sit here and flame my post.
    Because your post bloody well deserved it.
    If you had any clue whatsoever, you'd find that I provide a lot of useful help to those who put some effort in themselves. All you seem to have done is post a URL to the homework and whine about how hard it all is.

    > How am I to complete an assignment when I do not know where to begin?
    Gee, how many times do you need telling?

    > I do not understand how to incorporate positions on board into the array?
    Now this is more like it, a specific question about a specific problem. If this is the only thing holding you back, then why didn't you ask it in the first place?
    Unless you state up front (by posting some code for example) a demonstration of the bits you can do and the bits you can't do (or are confused about), then stuff like your first post is just going to get flamed every single time.
    And to answer your question, study how pos / 3 and pos % 3 may help you figure out grid coordinates for your game board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    @the_lumin8or:
    Stop wasting our time. We're not some C++ Noobs Anonymous help/care group. This forum is for specific problems and errors, not for teaching you how to do things. Go ask your professor/teacher/lecturer if you don't know where to start. If you didn't listen in class, well go f*** yer @$$, we're not gonna teach you.

    If you have a problem, post it in black+white, including code. Then explain your problem nicely. Otherwise don't expect any help at all.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I so enjoy these threads.

    Code; fail; then ask.

    Otherwise you just want us to do it for you.

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    I think we're done here.
    If the OP actually gets to write some code which they need help with, then post it in a new thread.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with my simple Tic tac toe prog
    By maybnxtseasn in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 06:25 PM
  2. Tic Tac Toe AI help please...
    By Rune Hunter in forum Game Programming
    Replies: 12
    Last Post: 11-05-2004, 03:24 PM
  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. Help with Tic Tac Toe game
    By snef73 in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2003, 08:33 AM
  5. my tic tac toe game, please try it
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2002, 05:16 PM

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