SRandom
Library for generating random numbers that have platform-independent consistency per a given seed.
- namespace SRandom
class SRandom[link]
Contains a seeded random session. Sessions seeded with the same value will generate the same random values.
new SRandom(seed)[link]
Creates a new seeded random session
Arguments
Name | Type | Description |
---|---|---|
seed | string | An arbitrary string to use as a seed. This string is hashed. |
function choice(list)[link]
Chooses an item randomly from a list.
Arguments
Name | Type | Description |
---|---|---|
list | List of any | Any lit |
Return Value
Type | Description |
---|---|
any | A random item from the list. |
function getBoolean()[link]
Gets a random boolean.
Return Value
Type | Description |
---|---|
boolean | a random boolean |
function getFloat()[link]
Gets a random float in the range of 0.0 up to but not including 1.0.
Return Value
Type | Description |
---|---|
float | a random float |
function getInteger(bound1, bound2)[link]
Gets the next random integer. If no bounds are given, this function will return a number from 0 through 2^31 - 1. If one bound is provided, that will serve as the exclusive upper bound, and this function will return a number from 0 through max - 1. If two bounds are provided, those will serve as the inclusive lower bound and exclusive upper bound, and this function will return a number from min through max - 1.
Arguments
Name | Type | Optional | Description |
---|---|---|---|
bound1 | integer | Optional | The exclusive maximum bound if this is the only number provided. If two numbers are provided, this is the minimum inclusive bound |
bound2 | integer | Optional | The exlusive maximum bound, if provided. This number must be higher than the first number. |
Return Value
Type | Description |
---|---|
integer | a random integer |
function shuffle(list)[link]
Shuffles a list randomly in place. The list is modified and nothing is returned.
Arguments
Name | Type | Description |
---|---|---|
list | List of any | Any list |