new test cases
worked on all walkers new helper methods new distributions some bugfixes
This commit is contained in:
@@ -46,7 +46,7 @@ public:
|
||||
;
|
||||
}
|
||||
|
||||
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T> start, const float distance_m) override {
|
||||
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T>& start, const float distance_m) override {
|
||||
|
||||
return GridWalkHelper::retryOrInvert(*this, 2, grid, start, distance_m);
|
||||
|
||||
@@ -60,13 +60,18 @@ private:
|
||||
// NOTE: allocate >>ONCE<<! otherwise random numbers will NOT work!
|
||||
DrawList<T*> drawer;
|
||||
|
||||
GridWalkState<T> walk(Grid<T>& grid, const GridWalkState<T> cur, float distRest_m) {
|
||||
GridWalkState<T> walk(Grid<T>& grid, const GridWalkState<T>& cur, float distRest_m, float headChange = -1) {
|
||||
|
||||
drawer.reset();
|
||||
GridWalkState<T> next;
|
||||
|
||||
// create a copy (to keep heading and walked distance)
|
||||
GridWalkState<T> next = cur;
|
||||
|
||||
// change the heading at the beginning of each walk
|
||||
if (headChange == -1) {headChange = headingChangeDist(gen);}
|
||||
|
||||
// get a new random heading
|
||||
next.heading = cur.heading + headingChangeDist(gen);
|
||||
next.heading = cur.heading + headChange;
|
||||
|
||||
// weight all neighbors based on this heading
|
||||
for (T& neighbor : grid.neighbors(*cur.node)) {
|
||||
@@ -81,8 +86,8 @@ private:
|
||||
const float prob1 = Distribution::Normal<float>::getProbability(0, Angle::degToRad(40), diffRad);
|
||||
|
||||
// add the node's importance factor into the calculation
|
||||
const float prob2 = Distribution::Logistic<float>::getCDF(neighbor.imp, 1.0, 0.05);
|
||||
//const float prob2 = std::pow(neighbor.imp, 10);
|
||||
//const float prob2 = Distribution::Logistic<float>::getCDF(neighbor.imp, 1.0, 0.05);
|
||||
const float prob2 = std::pow(neighbor.imp, 10);
|
||||
|
||||
// final importance
|
||||
const float prob = prob1 * prob2;
|
||||
@@ -106,13 +111,18 @@ private:
|
||||
// }
|
||||
|
||||
// get the distance up to this neighbor
|
||||
distRest_m -= next.node->getDistanceInMeter(*cur.node);
|
||||
const float walked_m = next.node->getDistanceInMeter(*cur.node);
|
||||
distRest_m -= walked_m;
|
||||
|
||||
// update the heading-change and walked-distance
|
||||
next.headingChange_rad += next.heading.getRAD() - cur.heading.getRAD();
|
||||
next.distanceWalked_m += walked_m;
|
||||
|
||||
// done?
|
||||
if (distRest_m <= 0) {return next;}
|
||||
|
||||
// another round..
|
||||
return walk(grid, next, distRest_m);
|
||||
return walk(grid, next, distRest_m, headChange);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user