Divooka Reference

Seeded Random

9 nodes

On this page 9

Make Seeded Random

Function

This node carries no documentation.

Signature
SeededRandom(seed: Integer) -> Seeded Random
SeededRandom SeededRandom(int seed = 1)

Parameters

nametypedefaultdescription
seedInteger1Which stream. Any value is a valid seed, including zero and negative numbers - the output function scrambles the state thoroughly enough that neighbouring seeds give unrelated streams.

Returns

resultSeeded Random
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Draws

Function

How many numbers have been drawn since the last SeededRandom.Restart.

Signature
Draws(Seeded Random: Seeded Random) -> Large Integer
long Draws(SeededRandom Seeded Random)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—

Returns

resultLarge Integer

Remarks

The position in the stream, and therefore the other half of its reproducibility: two runs that agree
on the seed and on this have drawn the same numbers. Worth asserting in a scripted run, because a
game that draws a different NUMBER of times is just as unreproducible as one that draws different
values.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Seed

Function

The seed this stream was made with.

Signature
Seed(Seeded Random: Seeded Random) -> Integer
int Seed(SeededRandom Seeded Random)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Next Around

Function

One of two numbers, either side of a middle, by an even coin flip.

Signature
NextAround -> Number
    Seeded Random: Seeded Random
    centre: Number
    spread: Number
double NextAround(
    SeededRandom Seeded Random,
    double centre,
    double spread)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—
centreNumber—
spreadNumber—

Returns

resultNumber

Remarks

The shape a spawner keeps needing: an obstacle's gap sits somewhere in a band around the centre of
the screen, and what varies is how far and which way. Saves a game writing the same two lines.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Next Between

Function

A number between two bounds, including the lower and excluding the upper.

Signature
NextBetween -> Number
    Seeded Random: Seeded Random
    minimum: Number
    maximum: Number
double NextBetween(
    SeededRandom Seeded Random,
    double minimum,
    double maximum)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—
minimumNumber—
maximumNumber—

Returns

resultNumber

Remarks

Bounds the wrong way round are swapped rather than refused: a spawn range typed backwards is
a slip, and refusing it would take a game down mid-run for something with an obvious meaning.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Next Chance

Function

Whether a thing with this probability happened.

Signature
NextChance -> Truth
    Seeded Random: Seeded Random
    probability: Number
bool NextChance(
    SeededRandom Seeded Random,
    double probability = 0.5)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—
probabilityNumber0.5From zero (never) to one (always).

Returns

resultTruth
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Next Unit

Function

A number from zero up to but not including one.

Signature
NextUnit(Seeded Random: Seeded Random) -> Number
double NextUnit(SeededRandom Seeded Random)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—

Returns

resultNumber

Remarks

Built from the top 53 bits, which is exactly what a double's mantissa holds - so every value is
representable and the distribution is even. Taking the low bits instead is the classic way to get a
generator that is subtly worse than the one it wraps.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Next Whole

Function

A whole number from the lower bound up to but not including the upper.

Signature
NextWhole -> Integer
    Seeded Random: Seeded Random
    minimumInclusive: Integer
    maximumExclusive: Integer
int NextWhole(
    SeededRandom Seeded Random,
    int minimumInclusive,
    int maximumExclusive)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—
minimumInclusiveInteger—
maximumExclusiveInteger—

Returns

resultInteger

Remarks

An empty or backwards range answers the lower bound, and draws nothing - there is no number
to pick, and advancing the stream for a question with no answer would make the sequence depend on how
often a game asked an impossible one.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime

Restart

Function

Go back to the beginning of the stream.

Signature
Restart(Seeded Random: Seeded Random)
void Restart(SeededRandom Seeded Random)

Parameters

nametypedefaultdescription
Seeded RandomSeeded Random—

Remarks

What restarting a run means for the spawner: the same seed gives the same world again.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Events Routine StateMachineState
Declared by
Seeded Random
Package
Glaze Realtime