Archive for the 'Flash' Category

17
Dec
08

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.

neural

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.

Why?
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#)

09
Dec
08

Fun with Flash: Assembler

Have you ever wanted to take some element, and then make a cool animation where it is assembled from a thousand different pieces? Well, me neither, until I saw a cool video of it. Then I wanted to see if I could make a Flash tool for it. Take a look at the result here.

Screenshot

Getting it to work
The first issue was to figure out where all the squares would have to go. On a suggestion from a colleague, I tried to use flocking to find the positions, which is why the source contains all the code necessary to make the blocks behave like boids :)

However, I quickly realized, that what I would achieve with flocking could much more easily be determined simply by finding pixels that were colored, as those represent the final text. By adding in a check that surrounding pixels also had to be colored, the blocks more or less would end up within the desired shape.

Tweens
Have you written code like “if( show && alpha < 1 ){ alpha += 0.1; }” many, many times? I have, and although you can fade in or out something with few lines of code, it gets old fast and adds some complexity to code that really should be about something else than fading in or out.

When I found this tweener library I was quickly sold. Not only will it let you easily fade things in and out, but it also allows for lots of other cool effects using many different transitions. I’ve added some of these transitions to the dropdown in Assembler, and the rest are trivial to add. For being trivial, they sure add some great effects and can change the overall feeling a lot.

End transition
Even with this effort and a great tween library, the squares still won’t fit the text completely. My solution here is to use PixelDissolve from one BitmapData to another, but it still looks a bit weird. I’ve thought about some better solutions, and will bring an update if I get around to trying them out.

Possible uses?
I only did this for fun and to see if I could. I never really thought about what it could be used for. If you have some ideas for games or anything cool this could be used for, then please let me know. I would love the inspiration :)

Download Source

05
Dec
08

Isometric Terrain Engine

On Flash forums you often come across people who are talking about or showcasing their brand new engine. But let me tell you: Unless you’re going to make game based on it yourself, odds are no-one will.

Creating an engine is a great learning experience and so was making this isometric terrain engine for me. However, without a concrete game design to aim for the engine will probably stay a technology showcase.

Isometric Terrain

It’s Always Performance
Making all the quirky rules of isometric terrain work (drawing order, line points) was a challenge, but once it was all set up it just works. Making it fast on the other hand …

The first version drew everything as vectors and could handle a 40×40 grid before grinding to a halt. With the second version I rendered the vectors to bitmaps and by the third version some further optimizations to the drawing routine made things quite fast and a cooler terrain generator was added :)

The fourth and final version got the ability to load in custom height maps, further optimizations where the map would be cached in the direction the user was scrolling, and a mini-map (it’s in the code, but was not added to the map in this version).

Transport Tycoon – the Flash version?
As a teenager I loved Transport Tycoon, and I’ve always wanted to make a game inspired by it. There is OpenTTD (Transport Tycoon Deluxe), which is great if you want to play on your desktop. But a Flash version with multiplayer, that would be fantastic.

That, and isometric terrains just being plain cool, were the reasons why I started this.

In the end
Getting to this point had been quite a lot of work. As I was just learning Flash, I realized the need to rework the entire project because some poor design decisions had been made. However, it was doubtful I could get it to run any faster. Transport Tycoon was out of the question as that would be a huge undertaking and I with my knowledge at the time it would never run fast enough. So without a clear game idea the project lingered …

All that was back in April/May 2007 and I’ve come a long way since. But I still think this is a pretty cool project, and I’m sure someone out there can get some inspiration from the code.

Download Source

Download earlier revisions




April 2014
M T W T F S S
« Dec    
 123456
78910111213
14151617181920
21222324252627
282930  

Months


Follow

Get every new post delivered to your Inbox.