Class LCGRandom
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
An lcg random generator, particularly suitable for worldgen See also https://en.wikipedia.org/wiki/Linear_congruential_generator
public class LCGRandom : IRandom
- Inheritance
-
LCGRandom
- Implements
- Inherited Members
- Extension Methods
Constructors
LCGRandom()
Initialize random with no seed. Use SetWorldSeed() to initialize
public LCGRandom()
LCGRandom(long)
Initialize random with given seed
public LCGRandom(long worldSeed)
Parameters
worldSeed
long
Fields
currentSeed
public long currentSeed
Field Value
mapGenSeed
public long mapGenSeed
Field Value
worldSeed
public long worldSeed
Field Value
Methods
InitPositionSeed(int, int)
Initializes a position dependent seed, if required
public void InitPositionSeed(int xPos, int zPos)
Parameters
InitPositionSeed(int, int, int)
Initializes a position dependent seed, if required
public void InitPositionSeed(int xPos, int yPos, int zPos)
Parameters
NextDouble()
Returns a random number from 0.0 - 1.0 (inclusive)
public double NextDouble()
Returns
NextFloat()
Returns a random number from 0.0F - 1.0F (inclusive)
public float NextFloat()
Returns
NextFloatMinusToPlusOne()
Returns a random number from -1.0F - 1.0F (inclusive) with a bias towards the zero value (triangle graph, similar to how rolling two 6-sided dice and adding the result is most likely to yield 7)
Precise to better than 15 binary digits / better than 4 significant figures in decimal
public float NextFloatMinusToPlusOne()
Returns
NextInt()
Returns a random number from 0 - int.MaxValue (inclusive)
public int NextInt()
Returns
NextInt(int)
Returns a pseudo random number from 0 - max (excluding max)
public int NextInt(int max)
Parameters
max
int
Returns
SetWorldSeed(long)
Sets given seed
public void SetWorldSeed(long worldSeed)
Parameters
worldSeed
long