RewindableRandomNumberGenerator
Inherits: RefCounted
Provides methods for generating pseudo-random numbers in the rollback tick loop.
Description
Using a regular RandomNumberGenerator in _rollback_tick() would generate different numbers on each peer. It also generates different numbers when resimulating the same tick.
This class solves all of the above, making it suitable for use during rollback.
The seed must be provided on instantiation, and must be the same on all peers for the random number generator to work properly.
Tutorials
Methods
| Return Type | Name |
|---|---|
| float | randf() |
| float | randf_range(float from, float to) |
| float | randfn(float mean, float deviation) |
| int | randi() |
| int | randi_range(int from, int to) |
Method Descriptions
float randf ( )
Returns a pseudo-random float between 0.0 and 1.0 (inclusive).
float randf_range ( float from, float to )
Returns a pseudo-random float between from and to (inclusive).
float randfn ( float mean, float deviation )
Returns a normally-distributed, pseudo-random floating-point number from the specified mean and a standard deviation. This is also known as a Gaussian distribution.
int randi ( )
Returns a pseudo-random 32-bit unsigned integer between 0 and 4294967295 (inclusive).
int randi_range ( int from, int to )
Returns a pseudo-random 32-bit unsigned integer between from and to (inclusive).