Constructor
new Seed($seed)
- Description:
- Creates a new seeded pseudo-random number generator.
- Source:
Example
const seed = new Seed(seed);
const random = seed.random();
Parameters:
| Name | Type | Description |
|---|---|---|
$seed |
number | The seed. |
Members
current :number
- Description:
- Gets the current seed.
- Source:
Gets the current seed.
Type:
- number
origin :number
- Description:
- Gets the seed of origin.
- Source:
Gets the seed of origin.
Type:
- number
Methods
random() → {number}
- Description:
- Gets a pseudo-random number (in [0, 1[ range) ("Mulberry32").
- Source:
Returns:
- Type
- number
range($minimum, $maximum) → {number}
- Description:
- Gets a pseudo-random number within the given range.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
$minimum |
number | The minimum value of the range. |
$maximum |
number | The maximum value of the range. |
Returns:
- Type
- number
shuffle($array) → {Array.<TypeGeneric>}
- Description:
- Shuffles the given array ("Fisher–Yates").
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
$array |
Array.<TypeGeneric> | The array to shuffle. |
Returns:
- Type
- Array.<TypeGeneric>
success($probability) → {boolean}
- Description:
- Performs a success roll based on the given probability (in [0, 1] range).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
$probability |
number | The probability to succeed. |
Returns:
- Type
- boolean