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:
JavaRandomfor thejava.util.Randomclass.JavaXoroshiro128PlusPlusfor theXoroshiro128PlusPlusPRNG.
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.JavaRandomCubiomes.JavaRNG.JavaXoroshiro128PlusPlusCubiomes.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_int32_range!(rng, 10)
3Cubiomes.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 TGenerate 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 TJump the state of the random number generator n steps forward, without generating any random numbers.
Cubiomes.JavaRNG.setseed🎲 — Methodsetseed🎲(rng::AbstractJavaRNG, seed) -> AbstractJavaRNGInitialize the rng with the given seed. Return the rng itself for convenience.