Neural nets playing tic tac toe

Started by
8 comments, last by Deyja 17 years, 9 months ago
I've just started experimenting with neural nets, and as a first effort I've got one playing tic tac toe. Demo at http://www.omnisu.com/ttt.zip When you first start it the neural net will be completely untrained. It will predict your next move (You play both sides yourself) and mark the spot with a red slash. When a game ends, just click to play again. I'd really like to know if anyone gets it to start exhibiting intelligent behavior. I repeated the exact same sequence of moves twenty-some times and it was predicting most of them correctly by the end.
Advertisement
First of all shame on you for making me download libpng13.dll and zlib1.dll

secondly ... nice work
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
Bleh, excising them from sdl-image would take me longer than everyone downloading them will ever take together.

Or, wait, did I not include them, and it wanted them? Or did I include them, but nothing in the thing uses them? Which are you mad about?
Okay, they weren't included; now they are, and I have to go figure out where they are hiding on my system, because it worked without them in the same folder as the exe for me. :/
Hey, neat program after about 10 games it was playing semi-intelligently.

I'm just starting to get into NNs so I was wondering how you represented the input and outputs. For the input I'm guessing it was just 9 different ones with -1 being Os , 0 being empty and 1 being Xs. Is that right?

How did you do the output tho? Did you just have two outputs for the x and y coords of the placement?
Bugboy
It doesn't care about x or o. Since it's predicting for both sides, the inputs were 1 for the current players piece, 0 for blank, and -1 for an enemy piece. The values x/o map to swap for every prediction. There are 9 outputs, each corrosponding to a square. I take the valid move with the largest value. I tried getting it to output the square with a single output, but then there was no recourse when it spit out an occupied square and I couldn't play against it.

Please notice that, since every move trains it, moving where the ai tells you, even if just for Os as if you were playing against it, will just reinforce those bad moves. :(
Quote:Original post by Deyja
Please notice that, since every move trains it, moving where the ai tells you, even if just for Os as if you were playing against it, will just reinforce those bad moves. :(


hehe, that's right, I started to fool around and made it quite stupid :P

anyway, i'ts a nice small app, and, If you didn't make the code too bizarr I guess it would be nice if you made it downloadable for begginers to see how you did it.
I would, except A) The internals of the neural net are based rather heavily on the book AI for Game Developers and B) I built it with my own framework stuff that brings in quite a bit of other code. Each square is a GUI widget, and it's got legitmate game states, and a virtual file system... and other good stuff.
I made a tic tac toe neural net just now except I'm using a genetic algie to train it and pitting it against a toned down minimax player to get the fitness.

It doesn't seem to be evolving too well tho. :(

How many neurons are in your hidden layer, Deyja? And are you using a sigmoid function?
Bugboy
9 and, if you are refering to the activation function; yes. Each of my layers has 9 nodes. I found that it adapts fastest at 3 nodes, actually; but doesn't retain knowledge well. Go lower then that (I tried with just 1 node in the hidden layer) and it seemed to just give the same move every time.

This topic is closed to new replies.

Advertisement