AI Battle again

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.

AI Battle

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);
  • outThrowBulletBoolean 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.

3 Responses to “AI Battle again”



  1. 1 The Fabrication Machine « ¿noʎ ǝɹɐ ʍoɥ 'ʎǝɥ Trackback on November 13, 2009 at 16:12

Ask a Question




Old stuff

October 2009
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031