Neural Nets and Visualization

Playing with AI is fun. That’s why I spent a lot of time trying to make a decent AI controller for Ms. Pacman and entered it into this competition. If you enjoy hard AI challenges I can definitely suggest you take a look at the competition, but ultimately I got pretty tired of Ms. Pacman 🙂

Although the best AI controller I created for Ms. Pacman used pretty simple AI, I spent a lot of time looking at several more advanced techniques, including neural nets. I never figured anything special out, but I did make a pretty flexible and fast-performing neural net in C# and a visualization using (the then pretty new) Windows Presentation Foundation – that version is in the link to the Ms. Pacman controller.


Now I’ve ported the neural net and visualization code to Flash. Take a look at the example here. It uses this test set.

The neural net has support for any amount of inputs, any amount of hidden layers with any amount of neurons as well as the most used activation functions. Also, porting the visualization was surprisingly easy going from WPF to Flash. The visualization cools (blue) when the weights (lines) and activation values for the neurons (boxes) stays unchanged, and warms (red) when they change. This can probably help you adjust the learning rate and size of the network, but beyond that it’s probably just nice to look at.

The most obvious question would be: why port a neural net to Flash from C#? The primary reason that I work with Flash is because it is so easy to get your projects into the hands of other people. I have worked with XNA for games as well, and just getting it to run on a computer without Visual Studio is beyond painful. So although I sacrifice some speed and ease of development when making hobby projects in Flash, it also gets to be a lot more fun – and usually prettier as well.

Download Source (Flash)

Download Source (C#)


5 Responses to “Neural Nets and Visualization”

  1. 1 Josh
    December 31, 2008 at 4:19 am

    How about posting the C# source code too? I don’t work with flash, but do a lot of C# coding and I would be interested to see your code. Nice work by the way, very interesting!

    • 2 yaief
      January 5, 2009 at 10:33 pm

      All the code is in the Ms. Pacman project I’ve linked to. But I’ve also provided a download link in the post directly to the C# Neural Net 🙂

  2. 3 paolo
    June 27, 2009 at 10:23 am

    Very interesing! Thanks for the code!

  3. July 6, 2009 at 11:54 am

    Long time, no posts, whats up?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

December 2008


%d bloggers like this: