22declare(strict_types=1);
33 public const X = 123456789;
34 public const Y = 362436069;
35 public const Z = 521288629;
36 public const W = 88675123;
59 public function setSeed(
int $seed) : void{
61 $this->x = self::X ^ $seed;
62 $this->y = self::Y ^ ($seed << 17) | (($seed >> 15) & 0x7fffffff) & 0xffffffff;
63 $this->z = self::Z ^ ($seed << 31) | (($seed >> 1) & 0x7fffffff) & 0xffffffff;
64 $this->w = self::W ^ ($seed << 18) | (($seed >> 14) & 0x7fffffff) & 0xffffffff;
67 public function getSeed() : int{
75 return $this->nextSignedInt() & 0x7fffffff;
82 $t = ($this->x ^ ($this->x << 11)) & 0xffffffff;
87 $this->w = ($this->w ^ (($this->w >> 19) & 0x7fffffff) ^ ($t ^ (($t >> 8) & 0x7fffffff))) & 0xffffffff;
89 return Binary::signInt($this->w);
96 return $this->nextInt() / 0x7fffffff;
103 return $this->nextSignedInt() / 0x7fffffff;
110 return ($this->nextSignedInt() & 0x01) === 0;
119 public function nextRange(
int $start = 0,
int $end = 0x7fffffff) : int{
120 return $start + ($this->nextInt() % ($end + 1 - $start));
123 public function nextBoundedInt(
int $bound) : int{
124 return $this->nextInt() % $bound;
nextRange(int $start=0, int $end=0x7fffffff)
__construct(int $seed=-1)