new test cases
worked on all walkers new helper methods new distributions some bugfixes
This commit is contained in:
@@ -22,7 +22,13 @@ public:
|
||||
const float d1 = h.getDiffHalfRAD(h1);
|
||||
const float d2 = h.getDiffHalfRAD(h2);
|
||||
//return (h.getDiffHalfRAD(h1) < h.getDiffHalfRAD(h2));
|
||||
return (d1 == d2) ? (rand() < RAND_MAX/2) : (d1 < d2); // same heading? > random decision
|
||||
//return (d1 == d2) ? (rand() < RAND_MAX/2) : (d1 < d2); // same heading? > random decision
|
||||
//return ((from.z_cm != n1.z_cm) && (from.z_cm == n2.z_cm)) ||
|
||||
// (d1 < d2) ||
|
||||
//(rand() < RAND_MAX/2);
|
||||
if (d1 < d2) {return true;}
|
||||
else if (d1 == d2) {return n1.z_cm != n2.z_cm;}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto neighbors = grid.neighbors(from);
|
||||
@@ -39,7 +45,7 @@ public:
|
||||
* if this also fails
|
||||
* - add some randomness and try again
|
||||
*/
|
||||
template <typename T, typename Walker> static GridWalkState<T> retryOrInvert(Walker& w, const int numRetries, Grid<T>& grid, GridWalkState<T> start, float distance_m) {
|
||||
template <typename T, typename Walker> static GridWalkState<T> retryOrInvert(Walker& w, const int numRetries, Grid<T>& grid, GridWalkState<T> start, float distance_m, const float headChange_rad) {
|
||||
|
||||
Assert::isTrue(distance_m >= 0, "distance must not be negative!");
|
||||
Assert::isNotNull(start.node, "starting node must not be null");
|
||||
@@ -53,13 +59,14 @@ public:
|
||||
// try to walk the given distance from the start
|
||||
// if this fails (reached a dead end) -> restart (maybe the next try finds a better path)
|
||||
do {
|
||||
res = w.walk(grid, start, distance_m);
|
||||
res = w.walk(grid, start, distance_m, headChange_rad);
|
||||
} while (res.node == nullptr && --retries);
|
||||
|
||||
// still reaching a dead end?
|
||||
// -> try a walk in the opposite direction instead
|
||||
if (res.node == nullptr) {
|
||||
res = w.walk(grid, GridWalkState<T>(start.node, start.heading.getInverted()), distance_m);
|
||||
GridWalkState<T> newState(start.node, start.heading.getInverted());
|
||||
res = w.walk(grid, newState, distance_m, headChange_rad);
|
||||
}
|
||||
|
||||
// still nothing found? -> modify and try again
|
||||
|
||||
Reference in New Issue
Block a user