JavaRNG

Cubiomes.JavaRNGModule

A 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:

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.

source

Index

API

Cubiomes.JavaRNG.JavaRandomType
JavaRandom(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)
3
source
Cubiomes.JavaRNG.next🎲Method
next🎲(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.

source
Cubiomes.JavaRNG.randjump🎲Method
randjump🎲(rng::AbstractJavaRNG, ::Type{T}, n::Integer) where T

Jump the state of the random number generator n steps forward, without generating any random numbers.

source
Cubiomes.JavaRNG.setseed🎲Method
setseed🎲(rng::AbstractJavaRNG, seed) -> AbstractJavaRNG

Initialize the rng with the given seed. Return the rng itself for convenience.

source

Private API

Click to see