isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
30 lines • 1.64 kB
TypeScript
import type { WeightedArray } from "../types/WeightedArray";
/**
* Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
* first element in the tuple is a value, and the second element in the tuple is a float
* corresponding to the value's weight.)
*
* If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
* parameter.
*
* @param weightedArray The array to pick from.
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
* a random seed.
*/
export declare function getRandomFromWeightedArray<T>(weightedArray: Readonly<WeightedArray<T>>, seedOrRNG: Seed | RNG | undefined): T;
/**
* Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
* first element in the tuple is a value, and the second element in the tuple is a float
* corresponding to the value's weight.)
*
* If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
* parameter.
*
* @param weightedArray The array to pick from.
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
* a random seed.
*/
export declare function getRandomIndexFromWeightedArray<T>(weightedArray: Readonly<WeightedArray<T>>, seedOrRNG: Seed | RNG | undefined): int;
//# sourceMappingURL=weighted.d.ts.map