Nice job puppy. I really like your battle field. Here is a battledroid. Better results against the first battledroid if you inicialize this.curAngle = 27.
Code:
var wallAt = -1;
for (var i=0; i< this.inColors.length; i++) {
if (this.inColors[i] == 0 && this.inDistances[i]<20) {
wallAt = i; break;
}
}
if ( wallAt > -1 ){
var minAngle = wallAt + 18;
var maxAngle = minAngle + 9;
var temp = Math.floor( Math.random()*(maxAngle-minAngle)+minAngle );
this.curAngle = (temp >35)?(temp%35):temp;
}
this.outMoveAngle = this.curAngle;
this.outMoveSpeed = this.inMaxSpeed;
if (this.inHasBullet){
var dangerAt = -1;
var enemyAt = -1;
for (var i=0; i< this.inColors.length; i++) {
if (this.inColors[i] == 3) {
dangerAt = i; break;
}
if (this.inColors[i] == 1) {
enemyAt = i; break;
}
}
if ( dangerAt > -1) {
this.outMoveAngle = ( dangerAt >26 ) ? ( 35-(dangerAt+9) ) : ( dangerAt-9 );
this.outMoveSpeed = this.inMaxSpeed;
if( this.inDistances[dangerAt]<50 ){
var enemyAt = -1;
for (var i=0; i< this.inColors.length; i++) {
if (this.inColors[i] == 1) {
enemyAt = i; break;
}
}
if ( enemyAt > -1){
this.outMoveSpeed = 0;
this.outThrowBullet = true;
this.outThrowAngle = enemyAt;
}
}
}
else if (enemyAt > -1 && this.inDistances[enemyAt]<250) {
this.outMoveSpeed = 0;
this.outThrowBullet = true;
this.outThrowAngle = enemyAt;
}
else{
this.outThrowBullet = false;
}
}
else
{
bulletAt = -1;
for (var i=0; i< this.inColors.length; i++) {
if (this.inColors[i] == 2) {
bulletAt = i; break;
}
}
if( bulletAt>-1 ){
this.outMoveAngle = bulletAt ;
this.outMoveSpeed = this.inMaxSpeed;
}
}
I want to try this one with more ("real") droids.