Photon Fusion 2.0.3

Public Member Functions | Static Public Attributes | Properties | List of all members
NetworkRNG Struct Reference

PCG32 random generator, 16 bytes in size. http://www.pcg-random.org More...

Inherits INetworkStruct.

Public Member Functions

 NetworkRNG (Int32 seed)
 Creates a new instance of NetworkRNG with a random seed. More...
 
double Next ()
 Generates a random double value within the inclusive range [0, 1]. More...
 
double NextExclusive ()
 Generates a random double value within the exclusive range [0, 1). More...
 
int NextInt32 ()
 Generates a random integer value within the range of int.MinValue to int.MaxValue. More...
 
float NextSingle ()
 Generates a random float value within the inclusive range [0, 1]. More...
 
float NextSingleExclusive ()
 Generates a random float value within the exclusive range [0, 1). More...
 
uint NextUInt32 ()
 Generates a random unsigned integer value within the range of 0 to uint.MaxValue. More...
 
Int32 RangeExclusive (Int32 minInclusive, Int32 maxExclusive)
 Returns a random Int32 within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped. More...
 
UInt32 RangeExclusive (UInt32 minInclusive, UInt32 maxExclusive)
 Returns a random UInt32 within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped. More...
 
Double RangeInclusive (Double minInclusive, Double maxInclusive)
 Returns a random Double within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped. More...
 
Int32 RangeInclusive (Int32 minInclusive, Int32 maxInclusive)
 Returns a random Int32 within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped. More...
 
Single RangeInclusive (Single minInclusive, Single maxInclusive)
 Returns a random Single within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped. More...
 
UInt32 RangeInclusive (UInt32 minInclusive, UInt32 maxInclusive)
 Returns a random UInt32 within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped. More...
 
override string ToString ()
 String representation of the RNG state. More...
 

Static Public Attributes

const UInt32 MAX = UInt32.MaxValue
 Maximum allowed value More...
 
const int SIZE = 16
 Size of the struct in bytes. More...
 

Properties

NetworkRNG Peek [get]
 Returns the same RNG instance. More...
 

Detailed Description

PCG32 random generator, 16 bytes in size. http://www.pcg-random.org

Constructor & Destructor Documentation

◆ NetworkRNG()

NetworkRNG ( Int32  seed)

Creates a new instance of NetworkRNG with a random seed.

Parameters
seedSeed value.

Member Function Documentation

◆ Next()

double Next ( )

Generates a random double value within the inclusive range [0, 1].

Returns
A random double value between 0 and 1, inclusive.

◆ NextExclusive()

double NextExclusive ( )

Generates a random double value within the exclusive range [0, 1).

Returns
A random double value between 0 (inclusive) and 1 (exclusive).

◆ NextInt32()

int NextInt32 ( )

Generates a random integer value within the range of int.MinValue to int.MaxValue.

Returns
A random integer value between int.MinValue and int.MaxValue, inclusive.

◆ NextSingle()

float NextSingle ( )

Generates a random float value within the inclusive range [0, 1].

Returns
A random float value between 0 and 1, inclusive.

◆ NextSingleExclusive()

float NextSingleExclusive ( )

Generates a random float value within the exclusive range [0, 1).

Returns
A random float value between 0 (inclusive) and 1 (exclusive).

◆ NextUInt32()

uint NextUInt32 ( )

Generates a random unsigned integer value within the range of 0 to uint.MaxValue.

Returns
A random unsigned integer value between 0 and uint.MaxValue, inclusive.

◆ RangeExclusive() [1/2]

Int32 RangeExclusive ( Int32  minInclusive,
Int32  maxExclusive 
)

Returns a random Int32 within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.

◆ RangeExclusive() [2/2]

UInt32 RangeExclusive ( UInt32  minInclusive,
UInt32  maxExclusive 
)

Returns a random UInt32 within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.

◆ RangeInclusive() [1/4]

Double RangeInclusive ( Double  minInclusive,
Double  maxInclusive 
)

Returns a random Double within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.

◆ RangeInclusive() [2/4]

Int32 RangeInclusive ( Int32  minInclusive,
Int32  maxInclusive 
)

Returns a random Int32 within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.

◆ RangeInclusive() [3/4]

Single RangeInclusive ( Single  minInclusive,
Single  maxInclusive 
)

Returns a random Single within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.

◆ RangeInclusive() [4/4]

UInt32 RangeInclusive ( UInt32  minInclusive,
UInt32  maxInclusive 
)

Returns a random UInt32 within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.

◆ ToString()

override string ToString ( )

String representation of the RNG state.

Member Data Documentation

◆ MAX

const UInt32 MAX = UInt32.MaxValue
static

Maximum allowed value

◆ SIZE

const int SIZE = 16
static

Size of the struct in bytes.

Property Documentation

◆ Peek

NetworkRNG Peek
get

Returns the same RNG instance.