PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
pocketmine\utils\Random Class Reference
+ Collaboration diagram for pocketmine\utils\Random:

Public Member Functions

 __construct (int $seed=-1)
 
 getSeed ()
 
 nextBoolean ()
 
 nextBoundedInt (int $bound)
 
 nextFloat ()
 
 nextInt ()
 
 nextRange (int $start=0, int $end=0x7fffffff)
 
 nextSignedFloat ()
 
 nextSignedInt ()
 
 setSeed (int $seed)
 

Public Attributes

const W = 88675123
 
const X = 123456789
 
const Y = 362436069
 
const Z = 521288629
 

Protected Attributes

int $seed
 

Detailed Description

XorShift128Engine Random Number Noise, used for fast seeded values Most of the code in this class was adapted from the XorShift128Engine in the php-random library.

Definition at line 32 of file Random.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\utils\Random::__construct ( int  $seed = -1)
Parameters
int$seedInteger to be used as seed.

Definition at line 48 of file Random.php.

References pocketmine\utils\Random\setSeed().

+ Here is the call graph for this function:

Member Function Documentation

◆ getSeed()

pocketmine\utils\Random::getSeed ( )

Definition at line 67 of file Random.php.

◆ nextBoolean()

pocketmine\utils\Random::nextBoolean ( )

Returns a random boolean

Definition at line 109 of file Random.php.

◆ nextBoundedInt()

pocketmine\utils\Random::nextBoundedInt ( int  $bound)

Definition at line 123 of file Random.php.

◆ nextFloat()

pocketmine\utils\Random::nextFloat ( )

Returns a float between 0.0 and 1.0 (inclusive)

Definition at line 95 of file Random.php.

◆ nextInt()

pocketmine\utils\Random::nextInt ( )

Returns an 31-bit integer (not signed)

Definition at line 74 of file Random.php.

◆ nextRange()

pocketmine\utils\Random::nextRange ( int  $start = 0,
int  $end = 0x7fffffff 
)

Returns a random integer between $start and $end

Parameters
int$startdefault 0
int$enddefault 0x7fffffff

Definition at line 119 of file Random.php.

◆ nextSignedFloat()

pocketmine\utils\Random::nextSignedFloat ( )

Returns a float between -1.0 and 1.0 (inclusive)

Definition at line 102 of file Random.php.

◆ nextSignedInt()

pocketmine\utils\Random::nextSignedInt ( )

Returns a 32-bit integer (signed)

Definition at line 81 of file Random.php.

◆ setSeed()

pocketmine\utils\Random::setSeed ( int  $seed)
Parameters
int$seedInteger to be used as seed.

Definition at line 59 of file Random.php.

Referenced by pocketmine\utils\Random\__construct().

+ Here is the caller graph for this function:

Member Data Documentation

◆ $seed

int pocketmine\utils\Random::$seed
protected

Definition at line 43 of file Random.php.

◆ W

const pocketmine\utils\Random::W = 88675123

Definition at line 36 of file Random.php.

◆ X

const pocketmine\utils\Random::X = 123456789

Definition at line 33 of file Random.php.

◆ Y

const pocketmine\utils\Random::Y = 362436069

Definition at line 34 of file Random.php.

◆ Z

const pocketmine\utils\Random::Z = 521288629

Definition at line 35 of file Random.php.


The documentation for this class was generated from the following file: