Package be.imgn.gaia.core.random
@NullMarked
package be.imgn.gaia.core.random
Randomness, with the source of it always given as an argument.
RandomSelector
selects one element at a time, uniformly or by weight, and MutableRandomSelector
does when the weights change. RandomTable draws several elements at once, some of
them from other tables. RandomBag and RandomSamples take elements without putting them back. RandomPermutation visits numbers in a random order. Chances are the exact chances of what selectors and tables give. Seed derives reproducible seeds, and RandomStrings makes
identifiers and tokens.-
ClassDescriptionChances<T>The exact chances of each outcome of something random: of each element that a
RandomSelectorselects, or of each multiset that aRandomTabledraws.A weightedRandomSelectorwhose elements and weights change: an element is added, removed or given another weight, and selected, in a time that grows with the logarithm of the number of elements.RandomBag<T>A bag to draw elements from at random, without putting them back: a deck of cards, or a list of options that must each come up once before any comes up again.The numbers from zero to a size, in a random order.Samples: several different elements taken at random among other ones, without taking any twice.Selects an element at random, each time it's asked to, with the source of randomness it's given.Random strings: identifiers, tokens and codes made of characters taken at random in an alphabet.RandomTable<T>A table to draw from at random: each draw gives a multiset of elements, made of the entries that are always given and of entries selected by weight, each of which is an element in some quantity, another table, or nothing.Builds aRandomTable.A seed from which other seeds are derived by name or by number, so that each part of a program has a random sequence of its own that only depends on the seed and on what the part is, not on what was generated before it.