-
Notifications
You must be signed in to change notification settings - Fork 1
TableRandomizer
Jump To | Go Back |
Arguments | Methods | Variables |
---|
Implements: Randomizer
Uses a pre-defined table of lookup values to return random numbers. This can be helpful if you wish to weight certain numbers, but has the drawback of requiring an array the size of the table. Each time a random number is drawn, the pointer in the table advances to the next one and returns the value stored there. You may provide your own table of numbers, or have one generated.
Output: A randomizer that contains a table of 256 values.
Name | Type | Purpose |
---|---|---|
seed | int |
The starting seed for this randomizer. If you are generating a table, this seed is used to generate the table instead. |
table | array |
The table of numbers to use. |
Jump To | top |
next | generate | from_array |
---|
Returns: int
Name | Type | Purpose |
---|---|---|
None |
Returns the next number in the table. If the last number has been read, the read position will return to the start of the table.
Returns: self
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
size | int |
The size of the table |
*rand | Randomizer | optional: If specified, will be used instead of GMS' functions |
Populates a new table of size elements using seed. The table will contain each number 0 to size - 1 inclusive. If size is not a number or is less than 1, or rand is not a Randomizer, InvalidArgumentType will be thrown.
Returns: self
Throws: InvalidArgumentType
Name | Type | Purpose |
---|---|---|
array | array |
The array of values |
Sets the table of values used to return numbers. If an array is not provided, InvalidArgumentType will be thrown.
Jump To | top |
---|
Name | Type | Initial | Purpose |
---|---|---|---|
__Table | array |
undefined | The table used to look up numbers |
Devon Mullane 2020