Constructor
new SeededRandom(seedopt)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
seed | number | <optional> | 1 | Starting integer or float seed. |
- Source
Classes
Members
initialSeed :number
The original seed this instance was initialized or re-seeded with.
- number
- Source
Methods
choice(array) → {T|undefined}
Select a random item from an array without modifying the array.
| Name | Type | Description |
|---|---|---|
array | Array.<T> |
- Source
- Type:
- T |
undefined
getState() → {Object}
Snapshot current internal state for serialization / checkpoints.
- Source
- Type:
- Object
next() → {number}
Advance the generator and return a uniform float in [0, 1).
- Source
- Type:
- number
nextBool(chanceopt) → {boolean}
Return true with probability chance (defaults to 0.5 for a 50/50 flip).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
chance | number | <optional> | 0.5 |
- Source
- Type:
- boolean
nextFloat(minopt, maxopt) → {number}
Return a uniform float in the range [min, max).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
min | number | <optional> | 0 | |
max | number | <optional> | 1 |
- Source
- Type:
- number
nextInt(min, max) → {number}
Return a uniform integer in the inclusive range [min, max].
| Name | Type | Description |
|---|---|---|
min | number | |
max | number |
- Source
- Type:
- number
setSeed(seed)
Re-seed the generator with a new seed value.
| Name | Type | Description |
|---|---|---|
seed | number |
- Source
setState(snapshot)
Restore internal state from a previously saved snapshot.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
snapshot | Object | State snapshot object containing numeric state. Properties
|
- Source
shuffle(array) → {Array.<T>}
In-place deterministic Fisher-Yates shuffle.
| Name | Type | Description |
|---|---|---|
array | Array.<T> |
- Source
- Type:
- Array.<T>