Class TCastleRandom
Unit
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
- TObject
- TCastleRandom
Overview
Methods
constructor Create(RandomSeed: LongWord = 0); |
|
procedure Initialize(RandomSeed: LongWord = 0); |
|
function Random: single; overload; |
|
function Random(N: LongInt): LongInt; overload; |
|
function RandomInt64(N: int64): int64; |
|
function RandomBoolean: boolean; |
|
function RandomSign: longint; |
|
function Random32bit: LongWord; |
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). |
function Random: single; overload; |
|
Returns random float value in the 0..1 range. |
function Random(N: LongInt): LongInt; overload; |
|
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.16.0.