API reference / @jsprismarine/worldgen / XoroshiroRandomSource
Class: XoroshiroRandomSource
Defined in: random/XoroshiroRandomSource.ts:120
A RandomSource running Xoroshiro128++ over 32-bit lanes.
Bit-for-bit equal to Xoroshiro128PlusPlus, which stays the slow reference this is tested against; the lanes avoid a BigInt allocation per operation, which matters because the aquifer and the ore vein rule build one of these per visited cell.
Implements
Constructors
Constructor
new XoroshiroRandomSource(
seedLo,seedHi):XoroshiroRandomSource
Defined in: random/XoroshiroRandomSource.ts:150
Parameters
seedLo
bigint
seedHi
bigint
Returns
XoroshiroRandomSource
Methods
consumeCount()
consumeCount(
rounds):void
Defined in: random/XoroshiroRandomSource.ts:275
Advances the stream by rounds draws without returning them.
Parameters
rounds
number
Returns
void
Implementation of
fork()
fork():
RandomSource
Defined in: random/XoroshiroRandomSource.ts:280
Returns an independent stream seeded from this one, advancing this one.
Returns
Implementation of
forkPositional()
forkPositional():
PositionalRandomFactory
Defined in: random/XoroshiroRandomSource.ts:285
Returns a positional factory seeded from this stream, advancing it.
Returns
Implementation of
nextBits()
nextBits(
bits):number
Defined in: random/XoroshiroRandomSource.ts:217
Returns the high bits from the next output without constructing a 64-bit bigint.
Parameters
bits
number
Returns
number
nextBoolean()
nextBoolean():
boolean
Defined in: random/XoroshiroRandomSource.ts:251
Returns the next boolean, taken from one bit of the stream.
Returns
boolean
Implementation of
nextDouble()
nextDouble():
number
Defined in: random/XoroshiroRandomSource.ts:263
Returns the next value in [0, 1) with 53 bits of precision.
Returns
number
Implementation of
nextFloat()
nextFloat():
number
Defined in: random/XoroshiroRandomSource.ts:257
Returns the next value in [0, 1) with 24 bits of precision.
Returns
number
Implementation of
nextGaussian()
nextGaussian():
number
Defined in: random/XoroshiroRandomSource.ts:269
Returns the next normally distributed value with mean 0 and standard deviation 1.
Returns
number
Implementation of
nextInt()
nextInt():
number
Defined in: random/XoroshiroRandomSource.ts:228
Returns the next 32-bit signed integer, with every value equally likely.
Returns
number
Implementation of
nextIntBounded()
nextIntBounded(
bound):number
Defined in: random/XoroshiroRandomSource.ts:234
Returns the next integer in [0, bound).
Parameters
bound
number
Returns
number
Throws
When bound is not positive, as Java does.
Implementation of
nextLong()
nextLong():
bigint
Defined in: random/XoroshiroRandomSource.ts:211
Returns the next 64-bit signed integer.
Returns
bigint
Implementation of
restoreState()
restoreState(
state):void
Defined in: random/XoroshiroRandomSource.ts:180
Restores this source from a JSON-parsed state, rejecting invalid lanes and fixed points.
Parameters
state
unknown
Returns
void
saveState()
saveState():
XoroshiroRandomSourceState
Defined in: random/XoroshiroRandomSource.ts:166
Returns the four unsigned state lanes and cached Gaussian value for replay.
Returns
fromLanes()
staticfromLanes(loHi,loLo,hiHi,hiLo):XoroshiroRandomSource
Defined in: random/XoroshiroRandomSource.ts:140
Builds a source from a 128-bit state given as four unsigned 32-bit lanes.
Parameters
loHi
number
loLo
number
hiHi
number
hiLo
number
Returns
XoroshiroRandomSource
fromSeed()
staticfromSeed(seed):XoroshiroRandomSource
Defined in: random/XoroshiroRandomSource.ts:135
Builds a source from a world seed, spreading it to 128 bits the way Java does.
Parameters
seed
bigint
Returns
XoroshiroRandomSource
fromState()
staticfromState(state):XoroshiroRandomSource
Defined in: random/XoroshiroRandomSource.ts:130
Builds a source from a 128-bit state, which fork and the positional factory produce.
Parameters
state
Returns
XoroshiroRandomSource