Murl Engine Lua Addon API  Version 1.0 beta
Murl.Util.Rng

The random number generator base class.

The base class is abstract and is implemented by the TT800, Well1024 and Marsaglia class.


Table members

Methods


RandBool()

Get a random Bool value.

Boolean RandBool()

Returns
Boolean The random Bool value.

RandUInt(from, to)

Get a random UInt32 value within a specified range. It is supported to pass a range of from > to.

Integer RandUInt(Integer from, Integer to)

Parameters
fromThe start of the range.
toThe end of the range.
Returns
Integer The random UInt32 value in range [from .. to].

RandSInt(from, to)

Get a random SInt32 value within a specified range. It is supported to pass a range of from > to.

Integer RandSInt(Integer from, Integer to)

Parameters
fromThe start of the range.
toThe end of the range.
Returns
Integer The random SInt32 value in range [from .. to].

RandReal(from, to)

Get a random Real value within a specified range. Scales (from - to) within a 32 bit random number. It is supported to pass a range of from > to.

Number RandReal(Number from, Number to)

Parameters
fromThe start of the range.
toThe end of the range.
Returns
Number The random Real value in range [from .. to].

RandDouble(from, to)

Get a random Double value within a specified range. Scales (from - to) within a 64 bit random number. It is supported to pass a range of from > to.

Number RandDouble(Number from, Number to)

Parameters
fromThe start of the range.
toThe end of the range.
Returns
Number The random Real value in range [from .. to].

Draw(distribution)

Draw an index from a distribution array. The distribution array contains numbers which are defining the probability of the partition. The higher the value of the partition, the higher is the probability of drawing the partition.

Integer Draw(Murl.Array.UInt32 distribution)

Parameters
distributionAn array of partitions.
Returns
Integer The index of the drawn partition or -1 if all partitions are zero.

DrawNoReplacement(distribution)

Draw an index from a distribution array with no replacement. Draw() and set the drawn partition to zero.

Integer, Murl.Array.UInt32 DrawNoReplacement(Murl.Array.UInt32 distribution)

Parameters
distributionAn array of partitions.
Returns
Integer The index of the drawn partition or -1 if all partitions are zero.
Murl.Array.UInt32 distribution An array of partitions.

DrawNoReplacement(distribution, decrement)

Draw an index from a distribution array with no replacement. Draw() and decrement the drawn partition by a specified value.

Integer, Murl.Array.UInt32 DrawNoReplacement(Murl.Array.UInt32 distribution, Integer decrement)

Parameters
distributionAn array of partitions.
decrementThe value to decrement the drawn partition. The drawn partition is set to zero if the decrement underflows the partition.
Returns
Integer The index of the drawn partition or -1 if all partitions are zero.
Murl.Array.UInt32 distribution An array of partitions.