rbx-weighted-random-picker
Version:
Generates functions which pick a random element of an array based upon their assigned relative probabilities.
12 lines (10 loc) • 442 B
TypeScript
/**
* Creates a function which returns a random element from options when called.
* @param options The elements which can be selected by the function
* @param relativeWeights An array which corresponds to each element in options, with each element being the relative probability of each corresponding option.
*/
declare function RandomPicker<T>(
options: T[],
relativeWeights?: number[]
): () => T;
export = RandomPicker;