Basic bot makc3d forked:4favorite:0lines:42license : see code comments modified : 2009-11-01 02:17:45 Embed Tweet package { import flash.display.Sprite; import flash.text.TextField; import flash.system.Security; dynamic public class DummyScript extends Sprite { /** * Basic bot for http://tinyurl.com/aibattle * @see http://makc3d.wordpress.com/2009/10/31/ai-battle-again/ */ public function DummyScript () { Security.allowDomain ("http://makc.googlecode.com/"); if (stage != null) { var tf:TextField = new TextField; tf.autoSize = "left"; tf.text = stage.loaderInfo.url; addChild (tf); } } public function behavior ():void { var i:int; if (!this.inHasBullet) { // no bullet, let's get it var bulletAt:int = -1; for (i=0; i< this.inColors.length; i++) { if (this.inColors[i] == 2) { bulletAt = i; break; } } // go up until we see it this.outMoveAngle = (bulletAt < 0) ? 27 : bulletAt; this.outMoveSpeed = this.inMaxSpeed; } else { // look around for enemy var enemyAt:int = -1; for (i=0; i< this.inColors.length; i++) { if (this.inColors[i] == 1) { enemyAt = i; break; } } if (enemyAt > -1) { // throw the bullet this.outThrowBullet = true; this.outThrowAngle = enemyAt; } // up we go this.outMoveAngle = 27; this.outMoveSpeed = this.inMaxSpeed; } } } } Code Fullscreen Preview Fullscreen ai battle Security.allowDomain length text addChild Sprite int sort new page view favorite forked pv472 Maze walker makc3d forked:0 favorite:0lines:38 (diff:37) tag: ai battle pv383 scooby56 bot makc3d forked:0 favorite:0lines:92 (diff:114) tag: ai battle pv398 hohoho bot makc3d forked:0 favorite:0lines:91 (diff:93) tag: ai battle pv377 parad0xl0g bot makc3d forked:0 favorite:0lines:83 (diff:71) tag: ai battle