Random

object Random(source)

Deprecated

Duplicate functionality

Deterministic Random using a seed to guarantee the same random values between iterations

Types

Link copied to clipboard
Link copied to clipboard

Properties

Link copied to clipboard
var rnd: Random
Link copied to clipboard

Functions

Link copied to clipboard
fun bool(probability: Double = 0.5): Boolean
Link copied to clipboard
fun cubic(position: Vector2): Double
fun cubic(position: Vector3): Double
fun cubic(x: Double, y: Double): Double
fun cubic(x: Double, y: Double, z: Double): Double
Link copied to clipboard
fun double(min: Double = -1.0, max: Double = 1.0): Double
Link copied to clipboard
fun double0(max: Double = 1.0): Double
Link copied to clipboard
fun fbm(position: Vector2, noiseFun: (Int, Double, Double) -> Double, type: Random.Fractal = Fractal.FBM, octaves: Int = 8, lacunarity: Double = 0.5, gain: Double = 0.5): Double
fun fbm(position: Vector3, noiseFun: (Int, Double, Double, Double) -> Double, type: Random.Fractal = Fractal.FBM, octaves: Int = 8, lacunarity: Double = 0.5, gain: Double = 0.5): Double
fun fbm(x: Double, y: Double, noiseFun: (Int, Double, Double) -> Double, type: Random.Fractal = Fractal.FBM, octaves: Int = 8, lacunarity: Double = 0.5, gain: Double = 0.5): Double
fun fbm(x: Double, y: Double, z: Double, noiseFun: (Int, Double, Double, Double) -> Double, type: Random.Fractal = Fractal.FBM, octaves: Int = 8, lacunarity: Double = 0.5, gain: Double = 0.5): Double
Link copied to clipboard
fun gaussian(mean: Double = 0.0, standardDeviation: Double = 1.0): Double
Link copied to clipboard
fun int(min: Int = 0, max: Int = Int.MAX_VALUE): Int
Link copied to clipboard
fun int0(max: Int = Int.MAX_VALUE): Int
Link copied to clipboard
fun isolated(fn: Random.() -> Unit)

Use this inside extend methods to get the same result between iterations

Link copied to clipboard
fun pareto(alpha: Double = 1.0): () -> Double

https://en.wikipedia.org/wiki/Pareto_distribution

Link copied to clipboard
fun perlin(position: Vector2, type: Random.Noise = Noise.LINEAR): Double
fun perlin(position: Vector3, type: Random.Noise = Noise.LINEAR): Double
fun perlin(x: Double, y: Double, type: Random.Noise = Noise.LINEAR): Double
fun perlin(x: Double, y: Double, z: Double, type: Random.Noise = Noise.LINEAR): Double
Link copied to clipboard
fun <T> pick(coll: Collection<T>): T
fun <T> pick(coll: Collection<T>, compareAgainst: Collection<T>): T
fun <T> pick(coll: Collection<T>, compareAgainst: Collection<T> = listOf(), count: Int): MutableList<T>
Link copied to clipboard
fun point(rect: Rectangle): Vector2
Link copied to clipboard
fun pop()

Use this to go back to seeded state

Link copied to clipboard
fun push()

Use this when you want to get non-deterministic values aka random every call Follow it by calling .pop

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun ring2d(innerRadius: Double = 0.0, outerRadius: Double = 1.0, count: Int = 1): Any
Link copied to clipboard
fun ring3d(innerRadius: Double = 0.0, outerRadius: Double = 1.0, count: Int = 1): Any
Link copied to clipboard
fun <T> roll(elements: Collection<T>, distribution: (Int) -> List<Double>): T
Link copied to clipboard
fun simplex(position: Vector2): Double
fun simplex(position: Vector3): Double
fun simplex(position: Vector4): Double
fun simplex(x: Double, y: Double, z: Double): Double
fun simplex(x: Double, y: Double, z: Double, w: Double): Double
Link copied to clipboard
fun unseeded(fn: () -> Unit)

Use this when you want to get non-deterministic values aka random every call

Link copied to clipboard
fun value(position: Vector2, type: Random.Noise = Noise.LINEAR): Double
fun value(position: Vector3, type: Random.Noise = Noise.LINEAR): Double
fun value(x: Double, y: Double, type: Random.Noise = Noise.LINEAR): Double
fun value(x: Double, y: Double, z: Double, type: Random.Noise = Noise.LINEAR): Double
Link copied to clipboard
fun vector2(min: Double = -1.0, max: Double = 1.0): Vector2
Link copied to clipboard
fun vector3(min: Double = -1.0, max: Double = 1.0): Vector3
Link copied to clipboard
fun vector4(min: Double = -1.0, max: Double = 1.0): Vector4