Constructors
constructor
- new Random<G>(generator: G): Random<G>
-
Properties
generator
generator: G
Methods
advance
- advance(): Random<G>
-
bool
- bool(): boolean
-
Returns boolean
chance
- chance(decimal: number): boolean
-
Returns boolean
choice
- choice<A>(...from: A): A[number]
-
Returns A[number]
clone
- clone<T>(requiresSynchronization?: boolean, initialState?: T): Random<G>
-
Parameters
-
Optional
requiresSynchronization: boolean
-
Optional
initialState: T
float
- float(): number
-
Returns number
- float(max: number): number
-
Returns number
- float(min: number, max: number): number
-
Returns number
- float(range: IRange): number
-
Returns number
getElement
- getElement<T>(array: T[]): T
-
Returns T
int
- int(max: number): number
-
Returns number
- int(min: number, max: number): number
-
Returns number
- int(range: IRange): number
-
Returns number
intInRange
- intInRange(min: number, max: number): number
-
Returns number
- intInRange(range: IRange): number
-
Returns number
intInRangeExponential
- intInRangeExponential(min: number, max: number, steepness?: number): number
-
Parameters
-
min: number
-
max: number
-
steepness: number = 5
Returns number
percent
- percent(minChance?: number, chanceOutOf?: number, ceil?: boolean): number
-
Parameters
-
minChance: number = 0
-
chanceOutOf: number = 100
-
ceil: boolean = true
Returns number
sampling
- sampling<T>(arr: T[], count: number): T[]
-
Returns T[]
shuffle
- shuffle<T>(array: readonly T[]): T[]
-
Returns T[]
shuffleInPlace
- shuffleInPlace<T>(array: T[]): T[]
-
Returns T[]
weightedChoice
- weightedChoice<T>(choices: WeightedOption<T>[]): T
-
Returns T
withGenerator
- withGenerator<T>(generator: G, execute: (() => T)): T
-
Parameters
-
generator: G
-
execute: (() => T)
Returns T
Generates a random boolean