Tic-Tac-Toe

Started by
21 comments, last by Kaanin 17 years, 6 months ago
No,
He's already said that he doesn't want a perfect AI that wins all the time
hence the roundabout suggestions that are neither dictionary lists nor minimax
Advertisement
I know he didn't, but I was just pointing out the fact that it was possible, and that the game is mathmatically *solved*. Asbestos' suggestion of a random chance of error would be a good partner to the now not-so-perfect AI method. And I was pointing out that experiance with minimax will be *invaluable* for more complicated board game types, if that is what he is interested in for the future. If not, then ignore my suggestion :D
i understand the minimax theory but not the code itself. could someone give me the source code for a simple game (tic-tac-toe etc.) an known language will do (i can understand the idea of the code without knowing the language)

thanks
My guess would be that he's aware that the game is a simple draw. Czarkirk, I think your suggestion was already mentioned earlier in the thread.

In case my post was missed, I have a few questions of my own:

If applying a neural network to tic tac toe (to apply a learning approach and practice with neural networks)

how would the neural network look? 27 inputs, 9 outputs, how many hidden layers, and how many neurons per hidden layer?

i know this is a matter of choice, but i was looking for a simple solution that an expert would feel like using.

also, how is feedback applied? i cannot find anything online explaining using feedback. i understand the net is given feedback based on the outcome of the game.. how is this fed through and how does it alter the weights of the synapses.

one more question: is it necessary to tweak any kind of threshold values in this neural network? or should all neurons pass on their value up their synapse to the next layer and ignore the concept of threshold completely (for this application)
Everyone hates #1.That's why a lot of idiots complain about WoW, the current president, and why they all loved google so much when it was new.Forget the fact that WoW is the greatest game ever created, our president rocks and the brainless buffons of America care more about how articulate you are than your decision making skills, and that google supports adware, spyware, and communism.
hmmm. minimax code....

would this help?
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
id like a full source please...
Quote:Original post by sharpnova

how would the neural network look? 27 inputs, 9 outputs, how many hidden layers, and how many neurons per hidden layer?


Why 27 inputs? I think you could do the same or better with just 9, with the states -1, 0 and 1. If that doesn't work, I'd go for 18, though, as having 9 neurons for "empty" is redundant, and will probably slow down your learning.

With almost all problems of this sort, where you're not trying to, say, create a cognitive model, or have some plan for what the different hidden layers ought to represent, you can do with just one hidden layer. Actually, all functions can be mapped by a three-layer ANN, although sometimes it's not worth it.

The number of hidden neurons is your own preference. I'd go for an hourglass-shaped network, to encourage generalization, so would have four or five hiddens.

Also, I'd help the network out a little bit by doing all the rotations for it. If someone started in the corner, I rotate the board so the network always saw a corner opening as the same opening. This is something we do in our heads, and a ANN could probably get, eventually, but it's nice to help it out. This changes 9x8x7... possible states into 3x5x... state tree.

Quote:
also, how is feedback applied? i cannot find anything online explaining using feedback. i understand the net is given feedback based on the outcome of the game.. how is this fed through and how does it alter the weights of the synapses.

Personally, I'd go for a GA here. Looking online, it seems quite a few other people have come up with the same conclusion. Alternatively, you could create a table of the best move in every situation, and apply backprop. However, this requires you to work out the best move each time, which rather defeats the purpose.

Quote:Original post by Moon 111
id like a full source please...

The link above you wasn't enough? I think the source code there was pretty good. Work through that and try to understand it.
The thing is I don't want to use a GA. I have another project which is applying GA quite nicely. I just want to learn how to apply back propogation. I've looked online and most sources give a vague explanation of how to do it but I'm trying to find specifics.

Let me give you an example and if you would be so kind as to tell me step by step how to apply back propogation, it would solve my dilemna completely.

I'll make this small so it won't be a pain in the butt:

3 layers
2 inputs(I1, I2), 3 hiddens(H1, H2, H3), 2 outputs(O1, O2)

so we have 12 weighted synapses given arbitrary values:

I1->H1 = .2
I1->H2 = .3
I1->H3 = .4
I2->H1 = .5
I2->H2 = .6
I2->H3 = .1
H1->O1 = .7
H1->O2 = .3
H2->O1 = .4
H2->O2 = .25
H3->O1 = .45
H3->O2 = .05

now let's say our inputs were .5 and .25

H1 = .225
H2 = .3
H3 = .225

O1 = .37875
O2 = .15375

let's say my desired outputs were..
O1 = .45
O2 = .05


how would I apply back propogation to evolve this network?
Everyone hates #1.That's why a lot of idiots complain about WoW, the current president, and why they all loved google so much when it was new.Forget the fact that WoW is the greatest game ever created, our president rocks and the brainless buffons of America care more about how articulate you are than your decision making skills, and that google supports adware, spyware, and communism.
heres some source code for back-propagation hope it helps

http://cortex.snowseed.com/neural_networks.htm

also i have a pdf on nueralnets and backpropagation wich covers alot of the math if u want me to email it to you.
Quote:Original post by sharpnova
I just want to learn how to apply back propogation. I've looked online and most sources give a vague explanation of how to do it but I'm trying to find specifics.


The simplest tutorial by far that I've found on backprop is at www.cs.ucc.ie/~dgb/courses/ai/notes/notes9.pdf. The first two pages are sufficient to code the algorithm, but he also has source-code and an example.

Note something that's confusing for beginers learning backprop: the backprop algorithm uses a function, g'(x), that depends on the activation function you have chosen. This function will be different for different activation functions. The function he gives in this tutorial is only if your activation function is the sigmoid function (which is handy, as sigmoid is probably the only function you'll need for a long time).

I still don't think tic-tac-toe is a good scenario for learning backprop, however. It should work fine for your mini-problem, though.

This topic is closed to new replies.

Advertisement