renamed the random int generator function
All checks were successful
default-pipeline default-pipeline #170
All checks were successful
default-pipeline default-pipeline #170
This commit is contained in:
parent
8136273b33
commit
fb7c0e7a5c
@ -60,11 +60,11 @@ class PlaceRepository
|
||||
return $places;
|
||||
}
|
||||
|
||||
private function getRandomForMapWithValidPano($numberOfPlaces, $select, array &$exclude, $randomSelection = null): ?Place
|
||||
private function getRandomForMapWithValidPano($numberOfPlaces, $select, array &$exclude, $pickRandomInt = null): ?Place
|
||||
{
|
||||
do {
|
||||
$numberOfPlacesLeft = $numberOfPlaces - count($exclude);
|
||||
$place = $this->selectRandomFromDbForMap($numberOfPlacesLeft, $select, $exclude, $randomSelection);
|
||||
$place = $this->selectRandomFromDbForMap($numberOfPlacesLeft, $select, $exclude, $pickRandomInt);
|
||||
if($place === null) {
|
||||
// there is no more never visited place left
|
||||
return null;
|
||||
@ -79,15 +79,15 @@ class PlaceRepository
|
||||
return $place;
|
||||
}
|
||||
|
||||
private function selectRandomFromDbForMap($numberOfPlacesLeft, $select, array $exclude, $randomSelection): ?Place
|
||||
private function selectRandomFromDbForMap($numberOfPlacesLeft, $select, array $exclude, $pickRandomInt): ?Place
|
||||
{
|
||||
if($numberOfPlacesLeft <= 0)
|
||||
return null;
|
||||
|
||||
if(!isset($randomSelection)) {
|
||||
if(!isset($pickRandomInt)) {
|
||||
$randomOffset = random_int(0, $numberOfPlacesLeft - 1);
|
||||
} else {
|
||||
$randomOffset = $randomSelection($numberOfPlacesLeft);
|
||||
$randomOffset = $pickRandomInt($numberOfPlacesLeft);
|
||||
}
|
||||
|
||||
// $select_unvisited->orderBy('last_time');
|
||||
@ -150,7 +150,7 @@ class PlaceRepository
|
||||
$selectOldPlaces->orderBy('last_time');
|
||||
|
||||
// selection algorithm with preference (weighting) for older places
|
||||
$gaussianRandomSelection = function($numberOfPlaces) {
|
||||
$pickGaussianRandomInt = function($numberOfPlaces) {
|
||||
$stdev = 0.2;
|
||||
$avg = 0.0;
|
||||
$x = mt_rand() / mt_getrandmax();
|
||||
@ -162,7 +162,7 @@ class PlaceRepository
|
||||
// look for n - numberOfUnvisitedPlaces places
|
||||
while(count($places) < $n)
|
||||
{
|
||||
$place = $this->getRandomForMapWithValidPano($numberOfOldPlaces, $selectOldPlaces, $exclude, $gaussianRandomSelection);
|
||||
$place = $this->getRandomForMapWithValidPano($numberOfOldPlaces, $selectOldPlaces, $exclude, $pickGaussianRandomInt);
|
||||
if(isset($place))
|
||||
{
|
||||
$places[] = $place;
|
||||
@ -173,5 +173,4 @@ class PlaceRepository
|
||||
return $places;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user