Showing posts with label ScienceSim. Show all posts
Showing posts with label ScienceSim. Show all posts

Tuesday, March 23, 2010

Evolution Simulation IV: Mutating critters at last!

As noted in my last post I was finding all sorts of problems with my region. Turns out that these were due to two things. First to control my critters I was killing them off bu broadcasting a commmand that triggers the llDie() function. But too many prims dying at once was messing up the asset server.

Also I was duplicating the critters en mass and that I led the server to treat my critters as the dreaded grey goo. Grey goo is a term for excessive rapid self replicating prims. See this discussion of the origin of the term from nanotechnology. When Second Life, and apparently OpenSim as well, detects too rapid prim replication this is treated as grey goo and a defense against this called the grey goo fence is activated.

Open Sim apparently doesn't warn you about this and I only discovered the problem when experimenting with my critters in Second Life. Second Life does warn you about grey goo and I got the warning rezzing even a small number of critters at once. Apparently the limit is about 240 rezzings in 6 seconds. Beyond that the ability to rez those prims is restricted. My inadvertant experiments suggest that in SL the limit may be more stringent than 240 rezzings in 6 seconds.

See http://lslwiki.net/lslwiki/wakka.php?wakka=GreyGooFence for a discussion of Grey Goo and the Grey Goo Fence.

This last week I worked out how to input and represent the critters genetics and the mutation routines. In my earlier systems I had the critters read their initial genetics from a note card. Instead I use the object description field to enter and store the genetics as a string of integers.

Right now the description field has 4 digits

position 1 = "1" or "2" "1" = haploid "2" = diploid. Right now the critters are strictly haploid so this position is ignored for now.

Position 2, 3, 4 are three loci each with 9 possible alleles represented by single character "0" through "9". For the haploid critters, this means there are 1,000 possible genotypes.

Since I mean my evolution simulation to be visual the genotypes in the three loci are used to make a vector that can be used with the llSetColor function.

So in the object description field the legitimate genetic description would be
"1045" . When a new critter is rezzed, the description can be passed to the offspring through the parameter in the llRezObject function.

I also wrote a mutation function:

string mutation(string start, float mforward, float mback)

Where the string is the genetic description, mforward and mback are forward and back mutation rates going forward to the next allele and mback the back mutation rate to the previous allele. So I assume if the allele is "7" then forward mutation would lead to a change to "8", and back would change from "7" to "6".

In addition another function setcolor(string thedata) takes the genetic string, isolated the loci and uses them to set the color of the critter and display the genetic description as using llSetText. I did this because just as in real populations most of the genetic variation leads to subtle variation in the population phenotypes over the short run.

The image shows the results. The critters started out with the color <.9, 0 .9> which sort of a light bluish green. After 4 generations of mutations if you look at the image you can see subtle differences resulting from successive mutations.

The critters still don't really interact with each other and wander around randomly, but not leaving my region. I did some work streamlining this routine so it was much more efficient.

Next up....adding simple natural selection to the mix.

Monday, March 8, 2010

Evolution Simulation III Devastation in Science Sim!

Well not quite. But I was testing my critters to see how big a population my parcel in Science Sim could hold. Everything was fine until I went to delete them using a listen event with llDie triggered by a chatted command. Guess what, 600 prims dying all at once causes the asset server to have a fit: a bit disconcerting but Mic Bowman got things fixed....




And immediately after Mic's fix:

















Thigs were still loading at this point. What Mic recommended is that I use a random number to determine when a particular critter is going to die so that when I issue the command to die the critters don't all die at once.

In SL this bit of code gives a quite realistic movement for my critters:

vector newpos = newcoodinates(llGetPos() ,3.0);

llSetRot(llEuler2Rot(<0,0,-pi/2>)*llGetRot());

llLookAt(newpos,1,0);

llSetPos(newpos);



But in OpenSim the critters don't seem to turn toward the target in response to llLookAt as they do in SL.


Saturday, February 20, 2010

The Selfish Herd: OpenSim Evolution Simulation II

Been a bit distracted by academics but this week worked a bit on my evolution simulation. First I put limits on my critters so that if they escape my parcel they die. Next I set up a controller that uses or at least attempts to use llGetParcelPrimCount in a timer event to count my organisms and kill them all if the population grows beyond a certain size.

The script is straightforward:

But the script does seem to update the prim count properly in OpenSim unless I touch the prim with the script. What's weird is that I have used a very similar script in SL and it updates fine.

The other thing I have been working on is the duplication script itself. I am using the basic script givenn in the LSL Wiki at this link.

http://lslwiki.net/lslwiki/wakka.php?wakka=ExampleSelfReplication

This gives a pretty complete list of precautions if you want to make self replicating critters. So should you decide that you need some sort of self replicating critters pay real close attention lest you get the grey goo.

Right now I have the basic replication scheme worked into my code but right now the critters replicate only on a command from me...so they are on a pretty tight leash. The picture accompanying this post is after 8 doublings from a single critter. My critter sensing prim did not pick up that there were more than 128 critters so it is good thing I am not letting these things replicate on their own! The critters remind me of a herd hence the Selfish Herd after W. D. Hamilton's famous paper: Geometry for the selfish herd. J. theor. Biol. 31:295-311.

Thursday, February 4, 2010

OpenSim Evolution Simulation I

This is the first progress report on what's going on with my OpenSim Artificial Life/Evolution simulation introduced in this post.

Since I am interested in social behavior I think a good place to start is simulating a population where prisoner's dilemma is operating. The term "game" here used in the game theoretic sense, gets its name from the following scenario:

Two suspects are arrested by the police. The police lack enough evidence for a conviction. The prisoners are kept separate and the prosecutor visits each of them with the same deal. If one testifies (defects from the other) against the other, and the other remains silent (cooperates with the other prisoner), the betrayer goes free and the silent accomplice receives the full 10-year sentence. If both remain silent (they cooperate with each other), each gets only six months in jail for a minor charge. If each betrays the other, each receives a five-year sentence. Each prisoner must choose to betray the other or to remain silent. Each one is assured that the other would not know about the betrayal before the end of the investigation.

(modified from http://en.wikipedia.org/wiki/Prisoner%27s_dilemma)

Now this scenario may not seem related to evolution but it turns out that this is exactly the sort of thing that happens when two animals related or not might have choices to cooperate or not with other animals either of the same species or sometimes other species.

A couple of design issues revolve around topics like how to link the organisms' behavor to genetics, represent the genetics of the interacting organisms and how to pass that genetics to offspring. To get a feel for the general strategy I have used in the past, go to this post.

One new technical issue is that unlike my genetics activities and my discrete generation evolution simulation, the organisms I am using here have to be able to replicate themselves independently of some command from me. Now that a scary thought since I don't want to over run a sim with thousands of little evolving critters.

Fortunately the LSL Wiki gives a good rundown on how to make non invasive self replicating critters. For instance have them be killed if they get out of your parcel. Right now my critters are able to detect the parcel boundary and turn away from the boundary....but I will add the kill feature as an additional safety.

One of LSL's safety features isn't going to work in my case. LSL recommends using a counter that is decremented by 1 each time an offspring is replicated from the parent. The value of the counter is passed as the integer parameter in the llRezObject function and when the counter reaches zero say after 10 generations the critter dies rather than replicating. The problem is that I use this parameter to pass the genetics from parent to offspring.

So I need to figure out how to prevent non invasive critters from over running my parcel. My first impulse was to have each critter sense the number of critters in the parcel and stop them from replicating when the parcel count gets to a certain point-kind of a parcel carrying capacity. And that might be a good idea but the simplest way to do it might be to have one object track the number of critters in in the parcel and periodically send that to all the critters using llRegionSay on a private channel and have the critters individually adjust their replication as required.

A more interesting option might be to use a sensor event to get the number of critters in a set radius around the sensing critter and use that to adjust the rate of reproduction, perhaps make it negative. So critters in a region with few others would be able to multiply more rapidly than those at higher densities. I already use a sensor event to let the critters detect each other so I could modify that to do this as well. This would actually be quite realistic since organism's reproductive rates are often affected by density dependent factors.

So here is what I am thinking on the replication issue:

1. Implement a die if beyond land owned by me along with my current boundary detection routine.
2. Implement a central controller that determines how many critters are in my region and either kills them all or stops them from reproducing further if they get too numerous beyond some large population size say 4,000.
3. Implement the sensor option to determine the density of critters and adjust the rate of local reproduction. Should be possible to tweek this so the population's maximum would tend to run at a lower limit than 4,000, say 2,000.

Maybe I am being paranoid but who knows what sort of chaotic things can happen with 2,000 artificial life forms run around a sim unchecked. It would be the equivalent of pythons in the Everglades and probably really annoy my neighbors.


This may be interesting in its own right as a simple population growth model even with out the complication of prisoner's dilemma! If you want to join the fun and see what's going on, IM me as Paul Decelles in ScienceSim or as Simone Gateaux in SL . Remember, you need to configure your client for OpenSim and set up a user account. Also Avatars do not port between SL and Opensim.

The ScienceSim site will get you started.: http://www.sciencesim.com/ Make sure you read and follow the directions and rules carefully.

PS: SLurls don't work in OpenSim as far as I can tell but if you are in OpenSim I am in
Oregon North 47, 184, 23 in the ScienceSim grid.

Saturday, March 21, 2009

OpenSim and INTEL's ScienceSim

A group from INTEL has been busy setting up a virtual world called ScienceSim using OpenSim and so over the last few days I took a little look. First about OpenSim: OpenSim can use a scripting language based on lsl and indeed you can use the standard SL viewer for OpenSim sites. However OpenSim is not centralized as is most of SL but is run on servers owned by different people and groups.

According to the OpenSim wiki, OpenSim:

  • Supports creating multiple 'worlds' in a single application instance.
  • Supports multiple clients and protocols - access the same world at the same time via multiple protocols.
  • Extensive ability to customize your avatar, both with custom clothing, skins, and attached objects.
  • Realtime Physics Simulation, with multiple engine options including ODE, PhysX, Bullet and more.
  • The ability to create content real time in the environment using in world building tools. What you see is what you get.
  • In world application development using a number of different languages, including LSL/OSSL, C#, JScript and VB.NET

You can have your own virtual world offline on your own computer or link a server so that people from the outside can visit. Plus its free and you don't have to pay $L to anyone. So let's see, I am at the $40/month tier so that means I pay $480 + $88 or $568/year so maybe it would pay to use my tier money and get my own server and load OpenSim. Also OpenSim has some really cool extensions to LSL. Check these out.

Of course the flip side is I have never run my own server and OpenSim is buggy at least when using the current SL client so it would be very difficult to bring freshmen or sophomore students into an OpenSim region. For example I had great difficulty teleporting and my avatar sometimes would not be easily controllable. How much of that is due to problems with the software vs the servers and connections is not clear to me. As an alternative to the SL viewer you can use a viewer called Hippo.

First getting there- You need to set up an account via the ScienceSim adminstration page. But read these instructions and follow them carefully. You will need to make another copy of your Second Life shortcut, rename it and change the target. Remember that OpenSim is not Second Life so that you need to register a new avatar. ScienceSim prefers that you use your real life name for your avatar; I chose to register Simone again since I am not working in ScienceSim's grid but did register with my carbon based world name.

When you open the log in page, the left hand side has a list of regions run on private servers linked to the ScienceSim grid but I recommend just logging in. It may look at first like you are going to Second Life but you are not!










When you first launch your viewer to enter ScienceSim, you get a default female avatar which you can customize just as in Second Life. But while visiting ScienceSim decided to keep things simple. So here I am rezzing at ScienceSim's orientation site which serves as your default home.

There are four regions in the main ScienceSim grid Galileo, Kepler, Newton and Einstein, the world map is shows just those four regions. However there are currently 46 regions in total as shown here, which is a bit confusing. But it makes sense when you consider that these other regions are not really set up for the most part for public display but used for visualizing scientific data.

Here are some various screen shots I took on my first visit:

Einstein Region














Kepler Region














Newton Region. This shows part of the amphitheater. There also an observatory build in ScienceSim from where you can teleport to some of the other regions connected to the grid.











There is kind of a fun marble launcher and several other goodies like that in the main grid but right now there is not a whole lot to see.

Since I am a biologist I was particularly hot to see some of the biology being done there and sent an inquiry to the site master and got a nice response inviting me to the user's meeting on Friday. Unfortunately people got really confused as to what time the meeting was so it really didn't happen as scheduled.

However I did find a friendly group of users and they invited me to join their discussion and then later on met some other users at the amphitheater. They use Skype for much of their conferencing so I had to download and set up skype on my machine but that was pretty painless and the sound quality was excellent, much better than SL's voice.

One of the people I met is Aaron Duffy who a grad student using OpenSim to simulate the population genetics of ferns and since some of my training is in population genetics, was interested to see that. So today I went back and he graciously gave me a tour and demo of his work which is just starting. His project superficially resembles the ecosystem working group effort in Second Life, in fact Aaron got onto his project from exposure to that group.

This is Aaron and in the back ground are shown the 3 basic stages of the fern life cycle. The tall structure that is not entirely in the frame represents a sporophyte. The upside down "hat" to the left of sporophyte stem is a gametophyte and the brown ball partially hidden by Aaron is the spore which of course is produced by the sporophyte. Guess what gametophytes produce. Hmmm.

His simulation tracks the details of the genetics of the population as the population evolves over time. So for me this was really neat to see. Right now he is working on interpretative slides to make his project more understandable to non population genetics geeks.