My natural selection module works pretty well but one concern was how to make it a bit more interesting. One obviously way to do that would be to make Cami's that move so that they are harder to spot and catch.
So since I really don't know a whole lot about making things move in Second Life, the first thing I did was develop a cami that will roam around randomly but stay in my land.
The strategy I developed builds on a function I had previously scripted for random movement of a prim:
//--------------------------------
vector newcoodinates(vector pos ,float pathlength, integer start)
{
integer icount;
float deltax;
float deltay;
vector temp;
float ground;
temp = llGetPos();
if (start = TRUE)
{
deltax = llFrand(pathlength)-pathlength/2;
deltay = llFrand(pathlength)-pathlength/2;
temp.x = temp.x + deltax;
temp.y = temp.y + deltay;
ground = llGround(<0.0,0.0,0.1>);
temp.z = ground;
if (llGetLandOwnerAt(temp) == llGetOwnerKey(llGetKey()))
{
return temp;
}
else {
return pos;
}
}
return temp;
}
//---------------------------------------------------
The idea is to take the prim's current position and update it with a "random" number between zero and some maximum path length. That's what this statement does in the one dimension:
deltax = llFrand(pathlength)-pathlength/2;
Since I want the cami's to hug the ground for the vertical dimension I use LSL's llGround function:
ground = llGround(<0.0,0.0,0.1>); the result is the vertical dimension.
One thing that flummoxed me for awhile was how to keep the cami in bounds. My original idea was to have the cami detect when it was on someone else's land and have it turn around and leave. But that turned out to be more difficult to script in a totally fool proof manner to this trigonometrically challenged scriptor. Besides, it seemed much better and nicer, to stop the cami from even entering someone's land in the first place:
So that's what this piece of code does:
if (llGetLandOwnerAt(temp) == llGetOwnerKey(llGetKey()))
{
return temp;
}
else {
return pos;
}
The rest of the basic movement script is deceptively simple:
default
{
state_entry()
{
do {
newpos = newcoodinates(llGetPos() ,2,start);
llSetRot(llEuler2Rot(<0,0,-pi/2>)*llGetRot());
llLookAt(newpos,1,0);
llSetPos(newpos);
llStopLookAt();
}
while (start==TRUE);
}
}
The rotation functions are sort of trial and error on my part but the cami's end up with an interesting waddling motion, so I am pleased with that even if it wasn't quite what I wanted at first.
Deceptively simple because I also needed toggle that stops the cami's so I can catch them and for determining the cami genotypes and phenotypes. Fortunately my previous cami scripts are easily modified to to work with my cami movement script.
The result is Natural Selection the Predator version right now at:
http://slurl.com/secondlife/Carmine/123/151/135
Just touch the light blue prim and 50 maddingly difficult to catch cami's will start swarming around:
The idea is to put yourself in the role of a predator selecting against one of the phenotypes. The phenotypes use my cami genetics scripts and it is possible to select against one of the phenotypes and eliminate the genes for that phenotype, but its harder than it looks.
This version will allow you to keep selecting until the the cami's derez at which point you must touch the blue prim again to rez the next generation of cami's using the ones you didn't get as the parent population. I may change this feature.
The main script in the cube again handles all the book keeping and generates a report tracking the allele frquencies when you touch it to rez the next generation.
By the way, when you touch one of the camis in your role as predators they explode red blood thanks to a little particle script...next will be sound effects.
So even if you don't know squat about population genetics or evolution, at least you get to blow up stuff. I guess there is a bit of adolescent even in the most prim and proper of us.
Oh if you visit, watch out for cami sharks.
This week I will be designing some suggested activities related to evolution using my cami system and also taking a few days for a trip to the Ozarks for springtime dogwood viewing, I hope.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment