tic tac toe AI algorithm?

This is a discussion on tic tac toe AI algorithm? within the General AI Programming forums, part of the Cprogramming.com and AIHorizon.com's Artificial Intelligence Boards category; ok so i coded a tic tac toe game(470 lines) and now I would like to implement some AI into ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    106

    tic tac toe AI algorithm?

    ok so i coded a tic tac toe game(470 lines) and now I would like to implement some AI into it so i can have the ability to play myself.. if you can point me into any direction as far as how an AI algorithm for this would work... I also attatched a c++ file so you can run it if you wish
    thanks cJ
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,182
    Look up "minimax".

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    there are 19683 possible board combinations, of which only a subset are actually valid. I wrote a tic tac toe AI about 20 years ago that basically just enumerated all possible boards, and kept a record of all moves in the game, when it won it increased the value of the moves it made, when it lost it decreased them. Then run it overnight playing against itself and it will train well enough. During training have it make random moves, but during actual play have it always pick the best possible move.

    It was simple, worked very well, and ran in under 1MB of memory total.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tic tac toe AI roadblock >:-(|)
    By dark_rocket in forum Game Programming
    Replies: 5
    Last Post: 06-12-2006, 05:13 AM
  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. help with tic tac toe look ahead algorithm
    By heero24 in forum C Programming
    Replies: 1
    Last Post: 03-07-2004, 04:39 AM
  4. tic tac toe AI
    By abrege in forum C++ Programming
    Replies: 4
    Last Post: 12-05-2002, 06:10 AM
  5. not 3x3 tic tac toe game AI
    By Unregistered in forum Game Programming
    Replies: 9
    Last Post: 08-29-2001, 04:02 AM

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