Look what I’ve found on my hard drive – AI battle simulator! This was AS2 ExternalInterface-powered thing, that allowed anyone to program blue and teal balls to move around simple maze, pick up green balls and throw into each other. Unfortunately, only three people actually wrote scripts for this thing.
Today, I ported it in AS3 and made it load SWFs that contain “bot” code, instead of relying on JavaScript. Thanks to wonderfl, however, you can still program “bots” in the browser. The sad fact is, wonderfl is the only flash community in the world where experiments like this can prompt any interest, so naturally I am taking it there.
The rules are simple: write an SWF having behavior() method in its main class, battle script will load your SWF and call this method every frame. It will set these input variables:
- inColors and inDistances – arrays of 36 numbers representing things your “bot” can see at 10 degrees intervals: colors are 0 for wall, 1 for enemy, 2 for bullets and 3 for bullets heading your way, distances are in pixels;
- inHasBullet is Boolean value indicating that you have a bullet;
- inMaxSpeed is max speed that you can move at;
In behavior() method you set following output variables:
- outMoveSpeed – how fast you want to go;
- outMoveAngle – where you want to go (a number from 0 to 35);
- outThrowBullet – Boolean value indicating that you want to throw bullet (if you have one);
- outThrowAngle defines the target direction.
I will soon post to wonderfl all three codes submitted back in 2007.
love the simualtor
hey, you had to record 1M points flights on that cube game.