Divooka Reference

Random

9 nodes

On this page 9

Pick at Random

Function

One item of a list, picked at random, every item equally likely.

Signature
From(items: IList<TType>) -> TType
TType From(IList<TType> items)

Parameters

nametypedefaultdescription
itemsIList<TType>—The items to pick from: a list or an array of anything.

Returns

ItemTType

Remarks

Each run picks differently. To pick the same way every run, use Pick From Generator with a Seeded Generator.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Pick From Generator

Function

One item of a list, picked with the given generator, every item equally likely; with a Seeded Generator the same picks come out every run.

Signature
From(items: IList<TType>, random: Random) -> TType
TType From(IList<TType> items, Random random)

Parameters

nametypedefaultdescription
itemsIList<TType>—The items to pick from: a list or an array of anything.
randomRandom—The generator to draw from, made by Seeded Generator.

Returns

ItemTType
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Pick at Random by Weight

Function

One item of a list, picked at random, each item's chance in proportion to its weight: an item weighted 2 comes up twice as often as one weighted 1, and one weighted 0 never does.

Signature
FromByWeight -> TType
    items: IList<TType>
    weights: IList<Number>
TType FromByWeight(IList<TType> items, IList<double> weights)

Parameters

nametypedefaultdescription
itemsIList<TType>—The items to pick from.
weightsIList<Number>—One weight for each item, in the same order, each zero or more.

Returns

ItemTType
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Pick by Weight From Generator

Function

One item of a list, picked with the given generator, each item's chance in proportion to its weight; with a Seeded Generator the same picks come out every run.

Signature
FromByWeight -> TType
    items: IList<TType>
    weights: IList<Number>
    random: Random
TType FromByWeight(
    IList<TType> items,
    IList<double> weights,
    Random random)

Parameters

nametypedefaultdescription
itemsIList<TType>—The items to pick from.
weightsIList<Number>—One weight for each item, in the same order, each zero or more.
randomRandom—The generator to draw from, made by Seeded Generator.

Returns

ItemTType
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Seeded Generator

Function

A random number generator that gives the same sequence every time it is given the same seed: for picks and numbers that come out the same every run, such as a procedural level or a test.

Signature
FromSeed(seed: Integer) -> Random
Random FromSeed(int seed = 42)

Parameters

nametypedefaultdescription
seedInteger42Any whole number; the same seed gives the same sequence.

Returns

GeneratorRandom

Remarks

Give it to the nodes that take a generator. The sequence for a seed holds within one .NET version but is not promised across major versions.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Random Number

Function

A random number from Min Value up to, but not including, Max Value, every value in between equally likely.

Signature
Range(minValue: Number, maxValue: Number) -> Number
double Range(double minValue = 0, double maxValue = 1)

Parameters

nametypedefaultdescription
minValueNumber0The lower end, which can come up.
maxValueNumber1The upper end, which does not; below the lower end, the number lies between the two the other way round.

Returns

NumberNumber
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Number From Generator

Function

A random number from Min Value up to, but not including, Max Value, drawn from the given generator; with a Seeded Generator the same numbers come out every run.

Signature
Range -> Number
    minValue: Number
    maxValue: Number
    random: Random
double Range(double minValue, double maxValue, Random random)

Parameters

nametypedefaultdescription
minValueNumber—The lower end, which can come up.
maxValueNumber—The upper end, which does not.
randomRandom—The generator to draw from, made by Seeded Generator.

Returns

NumberNumber
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Random Whole Number

Function

A random whole number from Min up to, but not including, Max: for a dice roll, 1 and 7.

Signature
Range(min: Integer, max: Integer) -> Integer
int Range(int min = 1, int max = 7)

Parameters

nametypedefaultdescription
minInteger1The smallest number that can come up.
maxInteger7One more than the largest number that can come up; equal to the smallest, it is always the smallest.

Returns

NumberInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library

Whole Number From Generator

Function

A random whole number from Min up to, but not including, Max, drawn from the given generator; with a Seeded Generator the same numbers come out every run.

Signature
Range(min: Integer, max: Integer, random: Random) -> Integer
int Range(int min, int max, Random random)

Parameters

nametypedefaultdescription
minInteger—The smallest number that can come up.
maxInteger—One more than the largest number that can come up.
randomRandom—The generator to draw from, made by Seeded Generator.

Returns

NumberInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Random
Package
Standard Library