Author Archive for Jonas Flensbak

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

14
Dec
08

Particle toys

You’ve probably tried at least one of them. Perhaps this one written in Java. When I first started to learn Flash I had a small competition with Chris from Nonoba about who could write the fastest sand particle “simulator”. I write “simulator” because it has obviously got nothing to do with any real physics, but it’s still a fun experiment.

Chris ended up writing this sandbox toy while I went in a slightly different direction and wanted to create something more computationally intensive to simulate: Water.

waters

Performance
Performance is obviously a huge issue in this kind of project as you really push the boundaries of how many pixels and operations Flash can pull through. If you want to know how I ended up approaching it, you will have to look through the code as it has been way too long. However, I do remember that it ended up being able to handle about 20% as many particles as Chris’ sand toy. 20% sounds like a low number, but it is actually quite fast considering the amount of checks that have to be made to make it seem water-like compared to sand-like. Whether it can be made with fewer operations is another question entirely :)

Game ideas
I originally had plans for making this toy into a game of sorts but although the effect is pretty cool, solid game ideas based on it were really hard to come by. I remember one game where you had to rescue lemming like creatures by pouring down sand to let them climb to the finish. It was nicely implemented, but stunningly boring as it was extremely slow and really just Lemmings with a twist that made the game worse than the original.

The best idea I came up with was to have a cavernous world filled with rock and water. Some rock you wouldn’t be able to carve through and other rock would be more soft. There would be a raft with people in it that would have to sail through the caves without hitting the bottom or the ceiling – so it would be up to you, the player, to either pour down water to raise the water level or remove the soft rock to lower it.

Download Source

And for the competition with Chris. I did find a faster way than his, which he ended up using in his Sand Toy with a few other optimizations :)

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

01
Dec
08

Open Source Zombies!

Zombies! is a team-oriented multiplayer game built on the Nonoba multiplayer platform. I’ve decided to open source it to give other developers a source for inspiration or to develop another game on the same code-base.

What it’s got

Zombies! has so far over 500k gameplays, 20 levels, boss-fights, multiple weapons and upgrades, 4 different enemies, and deathmatch. It’s stable and it’s pretty simple for a game of its size with almost no code on the Flash timeline, so it won’t be impossible for other developers to quickly get an overview.

zombies

What I want you to do

Download the source and take a look. You might learn something ;) You have a free license to do anything you want with the codefiles that are not from Nonoba or otherwise contains a license notice.

If you want to make your own sequel to Zombies! or a differently themed games you must create or find your own graphics and sounds. How you decide to tweak the game beyond that is completely up to you. As long as you tell everyone about it if you do something fun with it :)

What could be cool

The game was programmed in about 60 hours, so a lot of corners had to be cut. I would love for someone to take the game and make some cool additions. Some examples could be:

  • Barriers / obstacles for the players to hide behind
  • A completely new theme: Make it about humans and orcs or something else
  • Make it possible for players to move around a bigger screen so more people can play at once
  • More monsters, more weapons, more levels, more upgrades

License

All code specific to Zombies! is hereby licensed under the mWTFPL, which is based on the WTFPL. Look it up if you don’t know it ;)

Download

Get Zombies! here

You need Visual Studio 2008 to compile the backend. Download it for free here.




September 2014
M T W T F S S
« Dec    
1234567
891011121314
15161718192021
22232425262728
2930  

Months


Follow

Get every new post delivered to your Inbox.