LlFrand: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Void Singer (talk | contribs)
m formatted example
Gally Young (talk | contribs)
m remove multi lang
Line 1: Line 1:
{{multi-lang}}{{LSL_Function
{{LSL_Function
|sort=Frand
|sort=Frand
|func=llFrand
|func=llFrand

Revision as of 11:21, 14 February 2008

Summary

Function: float llFrand( float mag );
0.0 Forced Delay
10.0 Energy

Returns a float that is pseudo random number in the range [0.0,mag) or (mag, 0.0].
The sign of mag matches the return.

• float mag Any valid float value

Specification

returns a pseudo random number in range [0.0, mag) or (mag, 0.0], depending upon the sign of mag.

Caveats

The random number generator is not a source of entropy.

Examples

<lsl> default {

   touch_start(integer total_number)
   {
       // When touched, say "Heads" with probability 0.5, 
       // otherwise, say "Tails."
       if ( llFrand(1.) < .5)
           llSay(0, "Heads");
       else
           llSay(0, "Tails");
   }

}

</lsl>

Useful Snippets

Pseudo-random_Number_Generator - Suitable for apps which require repeatable results that feel random.

Notes

The random number generator is not a source of entropy.

The sequence of random numbers are shared across the entire process, and not independently seeded. Therefore, the pseudo random number generation is not suitable for any application which requires completely predictable or completely unpredictable results.

See Also

Functions

•  llListRandomize

Deep Notes

Signature

function float llFrand( float mag );