Skip to content

Randomness

Package: RANDOM_PACKAGE. Registered by createEngine(); for a slimmer engine, register it explicitly (see choosing packages).

Everyday random helpers: draw an identifier, pick one option out of several, shuffle a list, toss a coin. It is the companion to the dice page, which covers roll, a random integer in a range; these are the general-purpose pickers.

Because each answer is drawn fresh, the results below change every time the line runs. Edit one and watch it re-roll, that is the point, so unlike the rest of the documentation these examples show no fixed answer.

uuid produces a random version-4 UUID, the xxxxxxxx-xxxx-4xxx-yxxx-… form used as a one-off identifier for a record or a file.

uuid

random hex N gives N random hexadecimal digits, handy for a short token or a throwaway key.

random hex 8

pick chooses one of its options at random; shuffle puts a list into a random order.

pick("north", "south", "east", "west")
shuffle [1, 2, 3, 4, 5]

coin is heads or tails, an even fifty-fifty.

coin

Randomness here comes from the same source the engine’s random() and dice rolls already use. pick returns whichever option it landed on unchanged, so the options can be text, numbers or any other value; shuffle expects a single list (a row or column), and keeps its orientation.