Replace rand with newer versions random_int

This commit is contained in:
Arkadiusz Kondas 2016-12-12 19:09:45 +01:00
parent 2363bbaa75
commit 4dc82710c8
2 changed files with 3 additions and 3 deletions

View File

@ -118,7 +118,7 @@ class Space extends SplObjectStorage
$point = $this->newPoint(array_fill(0, $this->dimension, null));
for ($n = 0; $n < $this->dimension; ++$n) {
$point[$n] = rand($min[$n], $max[$n]);
$point[$n] = random_int($min[$n], $max[$n]);
}
return $point;
@ -243,7 +243,7 @@ class Space extends SplObjectStorage
$sum += $distances[$point] = $distance;
}
$sum = rand(0, (int) $sum);
$sum = random_int(0, (int) $sum);
foreach ($this as $point) {
if (($sum -= $distances[$point]) > 0) {
continue;

View File

@ -33,7 +33,7 @@ class Synapse
*/
protected function generateRandomWeight(): float
{
return 1 / rand(5, 25) * (rand(0, 1) ? -1 : 1);
return 1 / random_int(5, 25) * (random_int(0, 1) ? -1 : 1);
}
/**