Provide docs for random number generators
This commit is contained in:
parent
b8291c7e1c
commit
95f1a304c9
@ -8,6 +8,9 @@ import net.minecraft.world.level.levelgen.RandomSupport
|
|||||||
import java.lang.StringBuilder
|
import java.lang.StringBuilder
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random number generator with insane period of at least 2^511
|
||||||
|
*/
|
||||||
class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenerator, RandomSource {
|
class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenerator, RandomSource {
|
||||||
private val state = IntArray(CMWC_STATE_SIZE)
|
private val state = IntArray(CMWC_STATE_SIZE)
|
||||||
private var carry = 0
|
private var carry = 0
|
||||||
|
@ -2,15 +2,23 @@ package ru.dbotthepony.mc.otm.core.util
|
|||||||
|
|
||||||
import net.minecraft.util.Mth
|
import net.minecraft.util.Mth
|
||||||
import net.minecraft.util.RandomSource
|
import net.minecraft.util.RandomSource
|
||||||
|
import net.minecraft.world.level.levelgen.LegacyRandomSource
|
||||||
import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian
|
import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian
|
||||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
||||||
import net.minecraft.world.level.levelgen.RandomSupport
|
import net.minecraft.world.level.levelgen.RandomSupport
|
||||||
import java.lang.StringBuilder
|
import java.lang.StringBuilder
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
|
|
||||||
// different from LegacyRandomSource minecraft uses in meaning that this class use different constants
|
/**
|
||||||
// and always use upper 32 bits instead of implementing BitRandomSource
|
* Simple and insanely fast random number generator, which can be used for seeding (initializing internal state) of other number generators.
|
||||||
// AND it uses all bits from provided seed
|
*
|
||||||
|
* While can be used on its own, it probably shouldn't.
|
||||||
|
*
|
||||||
|
* Differs from [LegacyRandomSource] (also LCG, created by [RandomSource.create]) Minecraft uses in:
|
||||||
|
* * Different constants (with supposedly/expected better statistical properties)
|
||||||
|
* * Always use upper 32 bits instead of implementing BitRandomSource and sampling some upper bits
|
||||||
|
* * Uses all bits from provided seed
|
||||||
|
*/
|
||||||
class LCG64Random(private var seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenerator, RandomSource {
|
class LCG64Random(private var seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenerator, RandomSource {
|
||||||
private val gaussian = MarsagliaPolarGaussian(this)
|
private val gaussian = MarsagliaPolarGaussian(this)
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ import net.minecraft.world.level.levelgen.RandomSupport
|
|||||||
import java.lang.StringBuilder
|
import java.lang.StringBuilder
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excellent number generator with guaranteed period of 2^255
|
||||||
|
*/
|
||||||
class Xoshiro256SSRandom private constructor(
|
class Xoshiro256SSRandom private constructor(
|
||||||
private var s0: Long,
|
private var s0: Long,
|
||||||
private var s1: Long,
|
private var s1: Long,
|
||||||
|
Loading…
Reference in New Issue
Block a user