Tuesday, December 12, 2006

Simple Simulations

It's finally time for me to hand in one of my final projects. And what might have I done this time? Some strange thing mocking airport security. As I write this, I'm thinking of more ways to actually make fun of airport security; but let's say for now it is quite advanced.

At it's heart, it's a simple game of "build the ideal maze". The computer passes in about 64 little smiley faces, and each has to be able to get through your maze as quickly as possible, or they just give up. But if they give up, they still need to navigate themselves out of the maze. The greatest challenge is probably building a maze that can accomodate the 3 different targets that a smiley can go for (exit = boarding the plane, exit = give up, other smiley to arrest it).

Then, there's the fun fact that it's all done in Flash. This project gave me a good idea of what can and cannot be done in Flash -- and for the record, this is an example of what can be, but shouldn't be, done in Flash. Reason? It's too slow. My poor laptop is having trouble running it -- placing down a tile in the maze just pauses the simulation while it recomputes the optimal paths and other things that it needs. I found myself caching as much as possible, creating huge arrays and never destroying them just to prevent calculating things twice -- if this were in C, I wouldn't need to do that... Also, those weights are adding more calculations to the breadth-first-search... hmm, need to find better algorithms.

The interesting thing about the simulation is that at times it bogs down (too many smileys in one location, each stuck for some reason or another) ends up naturally fixing itself up; if it is given time. It forms clear dips in the output statistics graph. But how can they get stuck if there is only 1 path? Well, checkpoints are the way to win the game; they stop your character, and if it stops for too long, it has to wait for an officer to unblock it. That means the others wait, get unhappy, and give up on boarding the plane (hence, you need multiple interrogation stations, and a clear path for the police to pass, and it's probably best giving a path for those that gave up so they don't get in the way)... I'm probably having more fun playing with it now, then anything else. So, back to having fun!!!

Weeeeeee!!!!

No comments:

Post a Comment