Questions about tic tac toe

This is a discussion on Questions about tic tac toe within the C++ Programming forums, part of the General Programming Boards category; Hello guys, I'm planning to create a simple tic tac toe game, user vs computer and I want to make ...

  1. #1
    nik
    nik is offline
    Registered User
    Join Date
    Nov 2010
    Posts
    44

    Questions about tic tac toe

    Hello guys, I'm planning to create a simple tic tac toe game, user vs computer and I want to make the computer to never lose

    I'm planning to create this in Java, but since java and C++ are quite similar, I decided to ask you here about this problem

    I have created a simple game where I can play with myself, for example I put a X and O where I want and get the final result etc

    now about my problem, I can see that I have to implement the minimax algorithm, the problem is that although I understand the concept of this algorithm it's difficult for me to figure out how to code it

    i want to ask the following things

    1) since i've made the game user vs user, all i need is to create an extra class that will work for the computer where i will have the minimax function that will just evaluate the next move right?
    2) in order to do (1) should I create an extra class for the tree, or is it better to do this recursively?
    3) and if I use recursion I need to find all the states that I can go from a single state in order to use the evaluation function right?

    the biggest issue that i have is the time, if I make a good recursion how much time would it actually take to find all the states? if it's more than 10 seconds, I would really choose a different way, for example the alpha beta algorithm, about the memory, I don't really have restrictions for it

    thanks in advance

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    As for the recursion, for a 3x3 board, it will appear instant.

    As for the architecture. Assuming the board is a class (which it probably should be), then yes, a "computer" class could just call the same function that your player function calls to move.

    Nobody can give you any more detail about the architecture without you telling us how your program is currently architected. So what's a class, what's in the main, and how does stuff interact? GUI? No GUI? Text GUI? Who deals with that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. Gui questions
    By h3ro in forum Windows Programming
    Replies: 2
    Last Post: 08-05-2008, 02:11 AM
  3. A few questions
    By Shotgun in forum C Programming
    Replies: 4
    Last Post: 03-24-2006, 01:39 PM
  4. Two Questions:
    By LordVirusXXP in forum C++ Programming
    Replies: 1
    Last Post: 12-25-2002, 06:57 PM

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