Go Back   kirupaForum > Art and Design > Battle

Reply
 
Thread Tools Display Modes
Old 10-28-2006, 05:58 AM   #1
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
So, folks. AI battle?

Seing how previous battle never started because noone ever come up with any sort of ready-to-use environment, i have decided to do something about it. In a few hours I am flying away for a business trip, so you will have enough time to play with this stuff, find some bugs in it, discuss improvements, battle rules, judgement procedure etc.

Here's simple short-term memory no-ai-at-all script to get you started:
Code:
if (!this.inHasBullet) {
    // no bullet, let's get it
    var bulletAt = -1;
    for (var 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 = -1;
    for (var 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;
 this.trace("Throwing @" + enemyAt);
    }
    // up we go
    this.outMoveAngle = 27;
    this.outMoveSpeed = this.inMaxSpeed;
}
So, will see you in three weeks.


Last edited by puppy; 10-28-2006 at 06:01 AM.. Reason: highlighting url
puppy is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?

Old 10-28-2006, 01:22 PM   #2
Bash321
Registered User
 
Bash321's Avatar
not working

__________________
Bash321 is offline   Reply With Quote
Old 10-29-2006, 06:22 AM   #3
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
I've just tried it from here, IE6SP1W2K, and it works just as I left it at home?
puppy is offline   Reply With Quote
Old 11-03-2006, 06:54 AM   #4
Bash321
Registered User
 
Bash321's Avatar
oh, sorry i just didnt understand something. Now its woking perfectly!

what does the inColors array store? bullets?

__________________
Bash321 is offline   Reply With Quote
Old 11-06-2006, 07:01 AM   #5
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
there are 36 directions (angles) that the bot can "see" in. inColors is supposed to be array of "colors" visible in every direction. "colors" are represented by numbers according to "color map" (click "info" button); using inColors you can determine what's there (pickable bullet, enemy, wall, or flying bullet). inDistances are simply distances to things in every direction.
puppy is offline   Reply With Quote
Old 11-06-2006, 02:48 PM   #6
Bash321
Registered User
 
Bash321's Avatar
would be nice to have a "end simulation" button, so you could alter the code and try again, not having to refresh the page.

im working on something already, not having much luck but... maybe later

and also the balls, in my opinion, shouldn't fly straight through walls. Keep it up!

__________________
Bash321 is offline   Reply With Quote
Old 11-08-2006, 10:59 AM   #7
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
were balls to not fly through walls, bots could pick them up and throw back into each other almost instantly. that, and also I would have to write more code :p
puppy is offline   Reply With Quote
Old 11-09-2006, 03:28 PM   #8
parad0xl0g
Registered User
 
parad0xl0g's Avatar
Location nowhere No way

Posts 56
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.
parad0xl0g is offline   Reply With Quote
Old 11-12-2006, 04:22 AM   #9
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
hey parad0xlog you are by now the only one who made a script, though I also posted this in few other places. looking at the code, could you explain why "if ( dangerAt > -1) {" check is inside of "if (this.inHasBullet) {" check?

PS: I will definetly add RESET button when I get home. I have found that on some systems refreshing the page also blanks the scripts

PPS: I think something like this
Code:
this.findColor = function (c, ***<SOMETHING else?>) {
var res = [];
for (var i=0; i< this.inColors.length; i++)
    if ((this.inColors[i] == c) && (***<OTHER checks?>))
      res[res.length] = i;
return res;
}
should be on every bots' construction.

Last edited by puppy; 11-12-2006 at 05:21 AM.. Reason: edited code in PPS
puppy is offline   Reply With Quote
Old 11-13-2006, 11:06 PM   #10
parad0xl0g
Registered User
 
parad0xl0g's Avatar
Location nowhere No way

Posts 56
Well, the idea was created from a previous droid, and is basically to program a counterattack, to send a bullet quickly against the enemy when it attacks.
Could you post some scripts from other people out of kirupa.com?
parad0xl0g is offline   Reply With Quote
Old 11-14-2006, 03:34 AM   #11
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
well here was that guy, niq, who said he's making one, but he haven't it posted yet. as far as I know this guy, he probably will create good script, if any.
puppy is offline   Reply With Quote
Old 11-26-2006, 03:08 PM   #12
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
hey all, someone made 2nd bot.
puppy is offline   Reply With Quote
Old 01-07-2007, 07:34 PM   #13
protonxp
.:Electricity:.
 
protonxp's Avatar
Location Inside my CPU

Posts 195
i've looked through some of these codes and want to know wether it is a plug and play which i don't think it is or is it a code that you have to attacth to a movie clip?

__________________



I'm working on an RTS ...
protonxp is offline   Reply With Quote
Old 01-15-2007, 05:40 AM   #14
puppy
Banned
Location 50°27′N 30°31′E

Posts 290
that's a code you paste into this webpage. edit: wooops I messed up something last time I uploaded that page, and noticed only now, whatta... yet it should work anyway.

Last edited by puppy; 01-15-2007 at 05:46 AM..
puppy is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:21 PM.

SHARE:

SUPPORTERS:

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com