new test cases

worked on all walkers
new helper methods
new distributions
some bugfixes
This commit is contained in:
2016-02-02 21:43:15 +01:00
parent ec86b07c43
commit 2e2c1a3004
18 changed files with 363 additions and 41 deletions

View File

@@ -45,20 +45,27 @@ public:
gen.seed(1234);
}
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T> start, const float distance_m) override {
return GridWalkHelper::retryOrInvert(*this, 2, grid, start, distance_m);
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T>& start, const float distance_m, const float headChange_rad) override {
return GridWalkHelper::retryOrInvert(*this, 2, grid, start, distance_m, -1);
}
private:
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) {
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;
// pick the neighbor best matching this new heading
next.node = &GridWalkHelper::getBestNeighbor(grid, *cur.node, next.heading);
@@ -71,13 +78,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);
}