/tg/ Station 13 - Modules - Types — Var Details - Proc Details

dirt_random

A stream of random draws seeded by text, the same on every server and in the reference generator, so a mask drawn here matches the reference's pixel for pixel. The nth draw, counting from 0, is md5("[seed]:[n]") cut to its first six hex digits: a 24-bit integer, which a DM number holds exactly.

Everything built on draws spends them in the reference's order. Never take a draw with rand() or prob(), and never take a modulo with % or %% on something that may come out negative: use DIRT_MODULO.

Vars

draw_countHow many draws the stream has made, which is the next draw's number.
seedThe text every draw hashes.

Procs

NewStarts a stream at its first draw.
chooseReturns one of options, from one draw.
drawReturns the next draw, a whole number from 0 to 16777215.
gaussReturns a normally distributed number, from two draws (Box-Muller).
randintReturns a whole number from low to high, both included, from one draw.
randomReturns the next draw as a fraction from 0 up to 1, never 1.
randrangeReturns a whole number from 0 up to count, never count, from one draw.
sampleReturns count of items without repeats, as a new list: a Fisher-Yates from the front, stopped after count draws. items is left as it was.
shuffleShuffles items in place, from the last position down (Fisher-Yates), with one draw for each position but the first.
uniformReturns a number from low up to high, from one draw.

Var Details

draw_count

How many draws the stream has made, which is the next draw's number.

seed

The text every draw hashes.

Proc Details

New

Starts a stream at its first draw.

Arguments:

choose

Returns one of options, from one draw.

Arguments:

Crashes:

draw

Returns the next draw, a whole number from 0 to 16777215.

The draw's number goes into the hash in full, as the reference writes it, never in scientific notation.

gauss

Returns a normally distributed number, from two draws (Box-Muller).

The first draw is turned round to 1 - random(), so the log never sees 0. DM's trigonometry takes degrees.

Arguments:

randint

Returns a whole number from low to high, both included, from one draw.

Arguments:

random

Returns the next draw as a fraction from 0 up to 1, never 1.

randrange

Returns a whole number from 0 up to count, never count, from one draw.

Arguments:

Crashes:

sample

Returns count of items without repeats, as a new list: a Fisher-Yates from the front, stopped after count draws. items is left as it was.

Arguments:

Crashes:

shuffle

Shuffles items in place, from the last position down (Fisher-Yates), with one draw for each position but the first.

Arguments:

Returns:

uniform

Returns a number from low up to high, from one draw.

Arguments: