10-28-2006, 05:58 AM
|
#1
|
|
|
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
|
|
|
11-06-2006, 02:48 PM
|
#6
|
|
|
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! 
__________________
|
|
|
11-09-2006, 03:28 PM
|
#8
|
|
|
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.
|
|
|
11-12-2006, 04:22 AM
|
#9
|
|
|
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
|
|
|
11-14-2006, 03:34 AM
|
#11
|
|
|
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.
|
|
|
11-26-2006, 03:08 PM
|
#12
|
|
|
hey all, someone made 2nd bot.
|
|
|
01-15-2007, 05:40 AM
|
#14
|
|
|
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..
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 11:21 PM.
|
|