Table of Contents

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

long

mapGenSeed

public long mapGenSeed

Field Value

long

worldSeed

public long worldSeed

Field Value

long

Methods

InitPositionSeed(int, int)

Initializes a position dependent seed, if required

public void InitPositionSeed(int xPos, int zPos)

Parameters

xPos int
zPos int

InitPositionSeed(int, int, int)

Initializes a position dependent seed, if required

public void InitPositionSeed(int xPos, int yPos, int zPos)

Parameters

xPos int
yPos int
zPos int

NextDouble()

Returns a random number from 0.0 - 1.0 (inclusive)

public double NextDouble()

Returns

double

NextFloat()

Returns a random number from 0.0F - 1.0F (inclusive)

public float NextFloat()

Returns

float

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

float

NextInt()

Returns a random number from 0 - int.MaxValue (inclusive)

public int NextInt()

Returns

int

NextInt(int)

Returns a pseudo random number from 0 - max (excluding max)

public int NextInt(int max)

Parameters

max int

Returns

int

SetWorldSeed(long)

Sets given seed

public void SetWorldSeed(long worldSeed)

Parameters

worldSeed long