Class AdvancedRandom
Provides a better alternative for the Random class, offering further functionality.
public class AdvancedRandom : Random
- Inheritance
-
AdvancedRandom
- Inherited Members
- Extension Methods
Constructors
AdvancedRandom()
Initializes a new instance of the AdvancedRandom class, using a time-dependent default seed value.
public AdvancedRandom()
AdvancedRandom(byte)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(byte seed)
Parameters
seedbyteA number used to calculate a starting value for the pseudo-random number sequence.
AdvancedRandom(double)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(double seed)
Parameters
seeddoubleA number, whose hash code will be used to calculate a starting value for the pseudo-random number sequence.
AdvancedRandom(short)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(short seed)
Parameters
seedshortA number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.
AdvancedRandom(int)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(int seed)
Parameters
seedintA number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.
AdvancedRandom(long)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(long seed)
Parameters
seedlongA number, whose hash code will be used to calculate a starting value for the pseudo-random number sequence.
AdvancedRandom(sbyte)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(sbyte seed)
Parameters
seedsbyteA number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.
AdvancedRandom(float)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(float seed)
Parameters
seedfloatA floating-point number, whose bit reinterpretation as an int will be used to calculate a starting value for the pseudo-random number sequence.
AdvancedRandom(ushort)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(ushort seed)
Parameters
seedushortA number used to calculate a starting value for the pseudo-random number sequence.
AdvancedRandom(uint)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(uint seed)
Parameters
seeduintA number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.
AdvancedRandom(ulong)
Initializes a new instance of the AdvancedRandom class, using the specified seed value.
public AdvancedRandom(ulong seed)
Parameters
seedulongA number, whose hash code will be used to calculate a starting value for the pseudo-random number sequence.
Methods
ExtendSample(long)
protected virtual long ExtendSample(long result)
Parameters
resultlong
Returns
ExtendSample(ulong)
protected virtual ulong ExtendSample(ulong result)
Parameters
resultulong
Returns
NextBoolean()
Generates a random bool.
public virtual bool NextBoolean()
Returns
NextByte()
public virtual byte NextByte()
Returns
NextByte(byte)
Generates a random byte within the range [0,
maxValue).
public virtual byte NextByte(byte maxValue)
Parameters
maxValuebyteThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextByte(byte, byte)
Generates a random byte within the range
[minValue, maxValue).
public virtual byte NextByte(byte minValue, byte maxValue)
Parameters
minValuebyteThe inclusive lower bound of the random number returned.
maxValuebyteThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextChar()
public virtual char NextChar()
Returns
NextChar(char)
Generates a random char within the range [0,
maxValue).
public virtual char NextChar(char maxValue)
Parameters
maxValuecharThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextChar(char, char)
Generates a random char within the range
[minValue, maxValue).
public virtual char NextChar(char minValue, char maxValue)
Parameters
minValuecharThe inclusive lower bound of the random number returned.
maxValuecharThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextDouble(double)
Generates a random double within the range [0,
maxValue).
public virtual double NextDouble(double maxValue)
Parameters
maxValuedoubleThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextDouble(double, double)
Generates a random double within the range
[minValue, maxValue).
public virtual double NextDouble(double minValue, double maxValue)
Parameters
minValuedoubleThe inclusive lower bound of the random number returned.
maxValuedoubleThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextInt16()
public virtual short NextInt16()
Returns
NextInt16(short)
Generates a random short within the range [0,
maxValue).
public virtual short NextInt16(short maxValue)
Parameters
maxValueshortThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextInt16(short, short)
Generates a random short within the range
[minValue, maxValue).
public virtual short NextInt16(short minValue, short maxValue)
Parameters
minValueshortThe inclusive lower bound of the random number returned.
maxValueshortThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextSByte()
public virtual sbyte NextSByte()
Returns
NextSByte(sbyte)
Generates a random sbyte within the range [0,
maxValue).
public virtual sbyte NextSByte(sbyte maxValue)
Parameters
maxValuesbyteThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextSByte(sbyte, sbyte)
Generates a random sbyte within the range
[minValue, maxValue).
public virtual sbyte NextSByte(sbyte minValue, sbyte maxValue)
Parameters
minValuesbyteThe inclusive lower bound of the random number returned.
maxValuesbyteThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextSingle(float)
Generates a random float within the range [0,
maxValue).
public virtual float NextSingle(float maxValue)
Parameters
maxValuefloatThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextSingle(float, float)
Generates a random float within the range
[minValue, maxValue).
public virtual float NextSingle(float minValue, float maxValue)
Parameters
minValuefloatThe inclusive lower bound of the random number returned.
maxValuefloatThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextUInt16()
public virtual ushort NextUInt16()
Returns
NextUInt16(ushort)
Generates a random ushort within the range [0,
maxValue).
public virtual ushort NextUInt16(ushort maxValue)
Parameters
maxValueushortThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextUInt16(ushort, ushort)
Generates a random ushort within the range
[minValue, maxValue).
public virtual ushort NextUInt16(ushort minValue, ushort maxValue)
Parameters
minValueushortThe inclusive lower bound of the random number returned.
maxValueushortThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextUInt32()
public virtual uint NextUInt32()
Returns
NextUInt32(uint)
Generates a random uint within the range [0,
maxValue).
public virtual uint NextUInt32(uint maxValue)
Parameters
maxValueuintThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextUInt32(uint, uint)
Generates a random uint within the range
[minValue, maxValue).
public virtual uint NextUInt32(uint minValue, uint maxValue)
Parameters
minValueuintThe inclusive lower bound of the random number returned.
maxValueuintThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
NextUInt64()
Generates a random ulong within the range [0, MaxValue]. May use up to 2 number generations due to double's lesser precision.
public virtual ulong NextUInt64()
Returns
NextUInt64(ulong)
Generates a random ulong within the range [0,
maxValue). May use up to 2 number generations due to
double's lesser precision.
public virtual ulong NextUInt64(ulong maxValue)
Parameters
maxValueulongThe exclusive upper bound of the random number returned. Must be greater than 0.
Returns
NextUInt64(ulong, ulong)
Generates a random ulong within the range
[minValue, maxValue). May use up
to 2 number generations due to double's lesser
precision.
public virtual ulong NextUInt64(ulong minValue, ulong maxValue)
Parameters
minValueulongThe inclusive lower bound of the random number returned.
maxValueulongThe exclusive upper bound of the random number returned. Must be greater than
minValue.
Returns
Sample(double)
protected virtual double Sample(double maxValue)
Parameters
maxValuedouble
Returns
Sample(double, double)
protected virtual double Sample(double minValue, double maxValue)