Jump to content

Rez on percentage


ItHadToComeToThis
 Share

You are about to reply to a thread that has been inactive for 639 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Just to provide another idea to try:

if( (llHash(llGenerateKey())%1000)<14 ){...}

is a more expensive alternative to llFrand that may or may not have minutely different randomness characteristics.

ETA: see below, quick fix is:

if( (llAbs(llHash(llGenerateKey()))%1000)<14 ){...}

 

Edited by Quistess Alpha
Link to comment
Share on other sites

13 hours ago, Quistess Alpha said:

Just to provide another idea to try:

if( (llHash(llGenerateKey())%1000)<14 ){...}

is a more expensive alternative to llFrand that may or may not have minutely different randomness characteristics.

llHash() can return negatives and modulo can handle negatives, so that return range would be -999 to 999 instead of 0 to 999, favoring < 14 even more.

  • Thanks 1
Link to comment
Share on other sites

23 hours ago, ItHadToComeToThis said:

I know I could do a random number [up to] 100.0 and if its [less than] 1.4 then rez the object, but I feel that's not exactly what I'm after. [corrections/ additions]

Another (rather expensive) method would be to add 14 [1]'s and 1000-14 = 986 [0]'s to a list, llListRandomize() it and step through it, rezing if you pick a [1] from the list, re-randomizing after you hit the end. That would result in a different kind of random distribution.

Quote
list rezChance;
integer indexRez;
integer shouldIRez()
{   integer ret = llList2Integer(rezChance,indexRez++);
    if(indexRez==1000)
    {   indexRez=0;
        rezChance = llListRandomize(rezChance);
    }
    return ret;
}
default
{
  state_entry()
  {   list one = [1];
      list zero = [0];
      integer n = 14;
      while(~--n)
      {   rezChance+=one;
      }
      n = 986;
      while(~--n)
      {   rezChance+=zero;
      }
      rezChance = llListRandomize(rezChance);
  }
  // testing analog for situation in which there is a chance ot rez:
  touch_start(integer n)
  {   if(shouldIRez())
      { llRezObject(...);
      }
  }
}
// Untested code, use with caution!

 

Edited by Quistess Alpha
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 639 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...