JavaRNG
Cubiomes.JavaRNG
— ModuleA module that mimics the behavior of Java's random number generators in Julia. Only the functionalities needed by the Minecraft Java Edition are implemented.
The rngs implemented are:
JavaRandom
for thejava.util.Random
class.JavaXoroshiro128PlusPlus
for theXoroshiro128PlusPlus
PRNG.
Only the [next🎲
] function is used to get random numbers. Instead of nextDouble
or nextInt
in Java, use next🎲(rng, Float64)
or next🎲(rng, Int32)
respectively.
Index
Cubiomes.JavaRNG.JavaRandom
Cubiomes.JavaRNG.JavaXoroshiro128PlusPlus
Cubiomes.JavaRNG.next🎲
Cubiomes.JavaRNG.randjump🎲
Cubiomes.JavaRNG.setseed🎲
API
Cubiomes.JavaRNG.JavaRandom
— TypeJavaRandom(seed::Integer)
A pseudorandom number generator that mimics the behavior of Java's java.util.Random
class.
Examples
julia> rng = JavaRandom(1234)
JavaRandom(0x00000005deece2bf)
julia> next🎲(rng, Int32, 10)
7
Cubiomes.JavaRNG.JavaXoroshiro128PlusPlus
— TypeJavaXoroshiro128PlusPlus(lo::UInt64, hi::UInt64)
JavaXoroshiro128PlusPlus(seed::Integer)
A pseudo-random number generator that mimics the behavior of Java's implementation of Xoroshiro128PlusPlus
PRNG.
Cubiomes.JavaRNG.next🎲
— Methodnext🎲(rng::AbstractJavaRNG, ::Type{T}) where T
next🎲(rng::AbstractJavaRNG, ::Type{T}, stop) where T
next🎲(rng::AbstractJavaRNG, ::Type{T}, start, stop) where T
Generate a random number of type T
from the given random number generator. If start
and stop
are provided, the random number will be in the range [start, stop]
. start
is default to 0
.
Cubiomes.JavaRNG.randjump🎲
— Methodrandjump🎲(rng::AbstractJavaRNG, ::Type{T}, n::Integer) where T
Jump the state of the random number generator n
steps forward, without generating any random numbers.
Cubiomes.JavaRNG.setseed🎲
— Methodsetseed🎲(rng::AbstractJavaRNG, seed) -> AbstractJavaRNG
Initialize the rng with the given seed. Return the rng itself for convenience.