Click to See Complete Forum and Search --> : Tic Tac Toe AI


vohom001
March 17th, 2009, 09:08 PM
Hi all, I am an A level student and really new to programming and we are meant to make a tic tac toe game where human player can play against computer, however so far I have only implemented the code for 2 human players and it detects if any1 wins...what I now need is AI for the computer's turn...

Can I please get any help to get started on the AI....

Ive attached full code in a word document and a screen shot of the program.

I use visual studio 2008...

EDIT: I did some research and lot of other developers made their game by using labels in array...but problem here is that they made it in VB6 where creating control array is as simple as copy and pasting and in vb.net its not......so I read the Microsoft's article on how to create (duplicate) controls array but I don't know how to merge that into my game even if i start all over again from scratch which I don't mind if it solves the problem.

Thank you.

dglienna
March 17th, 2009, 10:30 PM
Just create a program that will play ITSELF, and you'll also have an automatic opponent, that can't be beat.

TT(n)
March 18th, 2009, 01:58 AM
Ha,
Number of players,... zero. (War games)

If it is to be intelligent artificially, then you'll nead to teach it futility.
Tic tac toe cannot be won, if played correctly by both players.
What player is to be the first to realize that there is no point in playing anymore.
The real winner.
It's also important to teach AI routines the concept of no.

I'd like to help, but why is the code in .doc form?

DataMiser
March 18th, 2009, 02:15 AM
There are probably several ways that you could do this, should be fairly simple. Basically you just need to have the code look at where the Xs and Os currently are and have the computer place it's X or O in the desired position. If it is done well then it will never be possible to beat the computer but just to make it interesting you could add in a random chance that the computer will make a mistake once in a while.