Chromosome Shuffler

From Second Life Wiki
Jump to navigation Jump to search

Created by Kira Komarov.

About

This is a chromosome shuffler system used on the science grid. It shuffles chromosome pairs such as "AA bb CC cc DD dd" randomly. For example a possible configuration would be:

AA aa
bb BB
CC cc
DD dd

as well as:

aa AA
BB bb
CC cc
dd DD

The way the script works, is that each chromosome row is indexed with a number. The "a" pair chromosome, for example, is the first row. The main script generates a random binary string such as:

0110

and sends that string through the linkset. Each row then picks up this string and selects the digit corresponding to that row. For example, the "a" pair chromosome row will take the first digit "0". If that digit has the value of 0, then no shuffling will be done. If that digit has the value 1, then the row will shuffle and "AA" will exchange position with "aa".

Setup

A possible set-up looks something like this:

File:Chromosome_shuffle.png

Where each of the differently colored slabs represent a chromosome pair.

  • The shuffle script should be placed in the root of the build.
  • The local coordinates (llGetLocalPos()) of each chromosome pair will have to be added to each script.
  • The vectors at the top of the chromosome script represent each slab's right position, respectively left position (For developers: this could be done differently by inverting the coordinates relative to the rezzer and perhaps eliminating half the need to manually enter coordinates).

Code

Shuffle Script

<lsl> ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // //////////////////////////////////////////////////////////

default {

   touch_start(integer num)
   {
       integer itra;
       list reconf;
       for(itra=0; itra<4; ++itra) {
           reconf += (string)llFloor(llFrand(2));
       }
       llMessageLinked(LINK_ALL_CHILDREN, 0, llList2CSV(reconf), "k@reconf");
   }

} </lsl>

Chromosome Script

<lsl> ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // //////////////////////////////////////////////////////////

vector left = <0.455429,1.375748,-0.020874>; vector right = <-0.276947,1.375740,-0.020874>; integer row =2;

default {

   link_message(integer sender_num, integer num, string str, key id)
   {
       if(id != "k@reconf") return;
       integer theDo = llList2Integer(llParseString2List(str, [","], [""]), row);
       if(!theDo) return;
       
       if(llVecDist(llGetLocalPos(), left)<0.2) {
           llSetPos(right);
           return;
       }
       if(llVecDist(llGetLocalPos(), right)<0.2) {
           llSetPos(left);
           return;
       }
   }

} </lsl>