Thread: random moves

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    73

    Question random moves

    I was wondering if anyone can suggest a way I can make the computers moves of my tic tac toe game random? We have yet to cover stuff like this, so any help?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Check out rand(), or random() if you have Borland.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    70
    Yeah, but rand() won't really make the computer "smart"...yea i know as a programmer it's our job to make the computer smart...but I'm in no state of denial...I'm a newbie...

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    73
    I am a newbie as well. And im using visual c++ 6.0. Its required for my class. So can anybody help?

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    What do you mean by 'smart' do you mean a leagal move or a good move.
    maybe I can help you

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    70
    I can do legal moves, but good moves is what i don't understand.

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You mean you want AI?

    Try something here. I don't know if this is any good.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60
    search the web for Minimax algorithm... one of the first things I created with the minimax function was a tic tac toe game, as a lot of people do. I am sure you will even find source code out there to look at.

  9. #9
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Hi,
    I think you should look for patterns, for example look for patterns where you could win with one move.
    Then look for patterns where the opponent can win with one move then put the mark on it so he can't and so on.
    You need to spend sometime on it, but it's wrothy...
    After all the TicTacToe is not that difficult.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 08:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 08:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM