Tic-Tac-Toe help needed

This is a discussion on Tic-Tac-Toe help needed within the C++ Programming forums, part of the General Programming Boards category; I am at the moment writing functions that will simulate an intelligent computer AI. I can get the 2 player ...

  1. #1
    Newbie2003
    Guest

    Tic-Tac-Toe help needed

    I am at the moment writing functions that will simulate an intelligent computer AI. I can get the 2 player function to work, but I cannot even think of a way to do a computer algorithm besides getting every single possible move that can happen and using them in huge if statements. Help plz.

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    www.generation5.org
    There's some good AI info on that site... especially for the type of problem you're using it for.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    AI for tictactoe is just a simple case of...

    If win_poss then win
    if loss_poss then stop_loss( sometimes its possible to lose on more than 1 square. You can only stop one).
    else take random untaken square.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Or you could go through every possibility, and see which move gives you the best chance of winning.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    As a matter of fact, if the computer moves second, it can always force a draw. If it moves first, then it can play in the center, which is a winning strategy if the other player doesn't play on a corner.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    the best algorithm (but hard) to implement for your tictactoe ai is the minimax tree.
    http://www.angrysoft.com/
    Get SMS Counter and Call Counter for Nokia 7650/3650

    http://www.angrysoft.com/tipsandtricks.php
    Please contribute some tips and tricks that you know of.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    my friend and i were bored in algebra class one day and decided to play tic tac toe, lol. anyways, there are SO many strategies to win a tic tac toe game.
    examples:
    1: take one corner
    if the middle is not taken take the opposite corner diagonally, if that is taken, take any corner
    take a corner that will possibly seal the win
    2: take a center square on the border
    take a corner on the other side of board
    take another corner
    3: take center
    take a center on the border
    take any corner

    just write strategies that could possibly work. then base your ai reactions on what strategies could be used.

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, 07:25 PM
  2. Help with Tic Tac Toe game
    By snef73 in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2003, 09:33 AM
  3. Tic Tac Toe Simple Game Needed!
    By Ruski in forum C++ Programming
    Replies: 13
    Last Post: 06-28-2002, 08:18 AM
  4. tic tac toe game
    By Leeman_s in forum Game Programming
    Replies: 9
    Last Post: 04-24-2002, 04:24 AM
  5. my tic tac toe game, please try it
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2002, 06:16 PM

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