Jump to content
  • Advertisement
Sign in to follow this  
Deyja

Neural nets playing tic tac toe

This topic is 4519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
First of all shame on you for making me download libpng13.dll and zlib1.dll

secondly ... nice work

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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. :/

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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. :(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!