-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
All PRNG or RNG have implement interface IRNG
.
All RNG's can be divided into 2, based on default output:
- Random 32-bit
- Random 64-bit
Here's the structure:
- IRNG
- Random
- Random32
- rng 32 bit
- Random64
- rng 64 bit
- Random32
- Random
- AlgorithmName()
- Reseed()
- NextBoolean()
- NextByte()
- NextByte(byte lower, byte upper)
- NextBytes(int length)
- NextInt()
- NextInt(uint lower, uint upper)
- NextLong()
- NextLong(ulong lower, ulong upper)
- NextDouble()
- NextDouble(double lower, double upper)
- Choice(T[] items)
- Choice(T[] items, int select)
- Sample(T[] items, int k)
- Shuffle(T[] items)
Return the name of the algorithm this RNG implements.
Seed the internal state from System.Security.Cryptography.RNGCryptoServiceProvider
.
If you want to manually seed the RNG or internal state, please create new instance. Because all RNG have different how they accept the seed, some accept 1 seed and some accept multiple seed.
Return a random C# true
or C# false
.
Return a random value from 0 to 255.
Return random number between lower
and upper
but the value must be in range 0 to 255.
-
lower
The lower bound or minimal value to generate.
-
upper
The upper bound or maximal value to generate.
-
ArgumentOutOfRangeException
The lower bound must not be greater than or equal to the upper bound.
Return array of bytes with length as requested.
-
length
Requested size or length of array.
-
ArgumentOutOfRangeException
The requested output size can't lower than or equal to 0.
Return a 32-bit unsigned integer.
Return random number between lower
and upper
but the value must be in range 0 to 4,294,967,295.
-
lower
The lower bound or minimal value to generate.
-
upper
The upper bound or maximal value to generate.
-
ArgumentOutOfRangeException
The lower bound must not be greater than or equal to the upper bound.
Return a 64-bit unsigned integer.
Return random number between lower
and upper
but the value must be in range 0 to 18,446,744,073,709,551,615.
-
lower
The lower bound or minimal value to generate.
-
upper
The upper bound or maximal value to generate.
-
ArgumentOutOfRangeException
The lower bound must not be greater than or equal to the upper bound.
Return a 64-bit floating point.
Return random number between lower
and upper
.
-
lower
The lower bound or minimal value to generate.
-
upper
The upper bound or maximal value to generate.
-
ArgumentOutOfRangeException
The lower bound must not be greater than or equal to the upper bound.
Return a random element from the given sets.
-
items
Set of items to choose.
Return multiple random element from the given sets.
-
items
Set of items to choose.
-
select
The desired amount to select.
- ArgumentNullException
- The items is null, empty or not initialized.
- ArgumentOutOfRangeException
- The number of elements to be retrieved is negative or less than 1.
- The number of elements to be retrieved exceeds the items size.
Select multiple distinct item from the sets.
-
items
Set of items to choose.
-
k
The desired amount to select.
- ArgumentNullException
- The items is null, empty or not initialized.
- ArgumentOutOfRangeException
- The number of elements to be retrieved is negative or less than 1.
- The number of elements to be retrieved exceeds the items size.
Shuffle items with Fisher-Yates shuffle.
-
items
Set of items to choose.
- ArgumentNullException
- The items is null, empty or not initialized.