Class TCastleRandom
Unit
CastleRandom
Declaration
type TCastleRandom = class(TObject)
Description
Custom, fast random number generator. Implementation of XorShift algorithm for random numbers generation. In some cases it works 2 to 3 times faster than native FPC random function. It also allows for multiple repeatable random seeds to support parallel pseudo-random sequences. The algorithm should not be used for cryptographic purposes, because it's speed-oriented (with quality ok for game, but not cryptographic use), and might subject to change in future.
Hierarchy
Overview
Methods
Description
Methods
 |
constructor Create(RandomSeed: LongWord = 0); |
Create and initialize (seed) the random generator. Parameter RandomSeed value 0 indicates to use a random seed (derived from current time and some other paramteres).
|
 |
procedure Initialize(RandomSeed: LongWord = 0); |
Initializes current seed. The seed must be a non-zero integer. Provide Zero value to initialize random seed based on current time (CPU ticks) and some other paramteres. This procedure is thread-safe, you'll get different random seeds even if initialization happens absolutely simultaneously.
|
 |
function Random: single; |
Returns random float value in the 0..1 range.
|
 |
function Random(N: LongInt): LongInt; |
Returns random integer number in the 0..N-1 range.
|
 |
function RandomInt64(N: int64): int64; |
A relatively slow procedure to get a 64 bit integer random number.
|
 |
function RandomBoolean: boolean; |
A simple Yes/No function that with 50% chance returns true or false. Something like flipping a coin...
|
 |
function RandomSign: longint; |
Randomly provides "-1", "0" or "1" with equal chances.
|
 |
function Random32bit: LongWord; |
Returns a random number in 1 .. High(LongWord) range.
|
Generated by PasDoc 0.15.0.
|