Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Design Concept: AI for physical vehicle

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
12-04-2006 13:41
Summary: A basic AI that will check for the edge of the world and avoid no_script enabled land, along with avoiding full parcels.

by Vehicle I am not reffering to an actual vehicle script, but instead an object that moves around using physics such as llMoveToTarget, llApplyImpulse, llApplyTorque, etc.


Key Concepts:

Using a constant cycling "List" within a timer event of things to do that the AI checks for. the frequency of this timer changes with the speed of the vehicle. Things which would be looked for in this list are:
  1. Am I going to run off the world?
  2. Am I going to enter a no-script area?
  3. Am I going to enter a full parcel and be returned to my owner's inventory?


Creating "Don't go here" zones by doing a quick scan of where it's moving to, and if it's listed as the edge of the world, no-script, or full parcel, it will pick a different spot. Alternatively I could have it "hop" over no-script land by setting it's altitude to 50m above the ground as it passes over such a zone, and then return to it's initial height once it's clear.

Border Crossings need to be handled carefully since it's very possible for an object to cross the border and end up in a "Don't go here" zone. llScriptDanger doesn't seem to work across borders. my current concept is if the vehicle wants to cross a border it will send out a probe (temp_on_rez) to check what's ahead (using a sensor for the probe). if the probe does not return within the set time the AI assumes that where it will cross into is a danger zone and does not move across the sim.

Any suggestions for other things a self-navigating AI needs to be aware of? I'm going to use the PHANTOM flag so it doesn't need to worry about running into anything besides the ground.

I'll update with a beta script once I work out the bugs/typos.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
12-04-2006 14:17
Yes. "Am I going to hit above 4096m and vanish off-world."
_____________________
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
12-04-2006 14:33
IIRC, probably not, but can't you get around noscript flags with greater altitude? Also, would the physical vehicle need to be aware of if some overzealous security script wacko's sentry llPushObjects it to an unexpected location? As in "Hmm. My scan shows that I'm now in a sim that I didn't cross into deliberately. I need to remember where I was and avoid it."
_____________________
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
12-04-2006 15:27
From: Kage Seraph
IIRC, probably not, but can't you get around noscript flags with greater altitude? Also, would the physical vehicle need to be aware of if some overzealous security script wacko's sentry llPushObjects it to an unexpected location? As in "Hmm. My scan shows that I'm now in a sim that I didn't cross into deliberately. I need to remember where I was and avoid it."



you can get around no-script flags with an altitude of 45m or greater above the ground height. This is one option that I'm considering (still working on general border crossing logic ATM). I had not thought of checking for unintentional sim crossing; I'll have to add that to the list. as far as hitting the 4096m mark, my intention is to allow the vehicle to rove around 5m above ground, but as was pointed out with the security script, I'll add in an altitude checker and probably use warppos to bring it back down if something tries to orbit the vehicle.


a problem I've found out is that those wonderful "auto-ban avatars that fly over my land" parcels now also prohibit my objects from entering said land. I do not know of a way to check for a key against some-one else's ban list, and am stumped in thinking of a way to get around that
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
12-04-2006 23:11
Here's my *Buggy* driver so far. I abandoned the list system for now, and am just using a simple point picker/checker whith llMoveToTarget to work out the kinks of navigating.

*vehicle script*
CODE

integer safeborder=TRUE;
vector moveto;
integer seconds;
integer checking;//For letting the script know if it was checking a point or not when it returns to the default state.



//checks if it's safe to move to the selected area
integer safezone(vector pos)
{
integer parcelFlags = llGetParcelFlags(pos);
if (parcelFlags & PARCEL_FLAG_ALLOW_SCRIPTS)
{
return TRUE;
}
else
{
return FALSE;
}
}



default
{
on_rez(integer num)
{
llResetScript();
}
state_entry()
{
llSetTimerEvent(5);
}

//Picks a random spot to move to within 10m of the vehicle
//every 5 seconds, and then checks to see if it's safe to
//move to said spot. If it's not safe to move, then the
//vehicle pics a different spot to move to.
timer()
{
float posx=llFrand(20) - 10;
float posy=llFrand(20) - 10;
float posz=llFrand(10) - 5;
if(checking==FALSE)
{
moveto=llGetPos()+(llVecNorm(llGetVel()) + llVecNorm(<posx,posy,posz>))*(llFrand(15)+5);
}
if(moveto.x < 0 || moveto.x > 256)
{
if(checking==FALSE)
{
state border_cross;
}
}
if(moveto.y <0 || moveto.y > 256)
{
if(checking==FALSE)
{
state border_cross;
}
}
if(moveto.z <llGround(<0,0,0>) || moveto.z > (llGround(<0,0,0>)+5))
{
vector mypos=llGetPos();
moveto.z=mypos.z;
}
if(safeborder==TRUE && safezone(moveto)==TRUE)
{
llSetText("Randomly exploring the grid is fun :)", <1,1,1>,1);
llMoveToTarget(moveto,5);
llLookAt(llGetPos() + llGetVel(),1,1);
llSleep(5);
}
else
{
llSetText("Selected position is dangerous to move to. /n Selecting new position...",<1,1,1>,1);
}

safeborder=TRUE;
checking=FALSE;

}
}

state border_cross
{
state_entry()
{
seconds=1;
checking=TRUE;
llSetText("Waiting for probe to check border",<1,1,1>,1);
llListen(-4169,"",NULL_KEY,"");
llSetTimerEvent(1);
llRezObject("probe",moveto,<0.0,0.0,0.0>,ZERO_ROTATION,0);
}


//The timer event shouts out the vehicle's location in global
//coordinates every second for the probe to grab (probably won't use).
//After 1 minute and 5 seconds, if nothing is heard back from
//the probe, the vehicle assumes the probe hit a danger zone
//and returns a false value for the safe border crossing
//before returning to the default (descision making) state.
timer()
{

//llSay(-4169,(string)myglobalpos);
seconds +=1;
if(seconds>=65)
{
llSetText("",<1,1,1>,1);
safeborder=FALSE;
state default;
}
}

//Listens for the probe to say the border is safe
listen(integer channel, string name, key id, string message)
{
if(message=="safe")
{
safeborder=TRUE;
state default;
}
}
}


***probe script***

CODE

default
{
state_entry()
{
llSetTimerEvent(1);
}

timer()
{
llShout(-4169,"safe");
}
}



I have a much better working/optimized vehicle and probe combo, but it got loose before I could take a copy and has been running for about 6 hours now without getting returned. Despite sending me it's location every 2 minutes I am unable to track it down to post said code. seems like a good sign that it's avoiding danger areas, but not being able to find it is very problematic.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
The Car!
12-05-2006 06:19
HAHAHA
You added AI to a car and it got loose in the world and now it won't come back?!?
I'll bet its creating mayhem: running down old ladies in crosswalks and mothers with baby buggies!
...sounds like a good movie plot
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
12-05-2006 09:05
I have a script that autopilots an object across the grid, avoiding the edges and it always stays at least 60m above ground level. However, it still seems to die in no script zones. I'm not sure that staying above 45m really works...unless someone actually has experience with it. I could never get it to work so I just created a system that reads a list of "unfriendly" sims from a notecard and the script avoids them like the plague. That, along with the edge of world detection system the script will allow my object to travel around the world for days :)

By the way, to find your lost vehicle. You could try attaching a scanner to you and teleporting to the last location that it was in. Using the scanner to detect and pinpoint its location you might be able to get it back. At least then you can expand your detection range to 96m while looking for it.
Logan Park
Registered User
Join date: 23 Sep 2006
Posts: 10
12-05-2006 12:37
Or to recover it just make sure it has a terra vehicle beacon in it. Easy peasy unless the sucker falls into a noscript trap. =)