started removing KLib related code:
- assertions - distributions new helper methods worked on stairs worked on grid-walkers worked on navigation
This commit is contained in:
@@ -40,7 +40,7 @@ public:
|
||||
*/
|
||||
template <typename T, typename Walker> static GridWalkState<T> retryOrInvert(Walker& w, const int numRetries, Grid<T>& grid, GridWalkState<T> start, float distance_m) {
|
||||
|
||||
_assertTrue(distance_m >= 0, "distance must not be negative!");
|
||||
Assert::isTrue(distance_m >= 0, "distance must not be negative!");
|
||||
|
||||
GridWalkState<T> res;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../Grid.h"
|
||||
|
||||
#include "../../math/DrawList.h"
|
||||
#include <KLib/math/distribution/Normal.h>
|
||||
#include "../../math/Distributions.h"
|
||||
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
const float diff = cur.heading.getDiffHalfRAD(potentialHeading);
|
||||
|
||||
// probability for this direction change?
|
||||
double prob = K::NormalDistribution::getProbability(0, HEADING_DIFF_SIGMA, diff);
|
||||
double prob = Distribution::Normal<float>::getProbability(0, HEADING_DIFF_SIGMA, diff);
|
||||
|
||||
// perfer locations reaching the target
|
||||
const double shortening = cur.node->distToTarget - neighbor.distToTarget;
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include "../Grid.h"
|
||||
|
||||
#include "../../math/DrawList.h"
|
||||
#include <KLib/math/distribution/Normal.h>
|
||||
#include <KLib/math/distribution/Exponential.h>
|
||||
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
|
||||
#include "GridWalkState.h"
|
||||
@@ -70,7 +67,7 @@ private:
|
||||
const float diffRad = potentialHeading.getDiffHalfRAD(cur.heading);
|
||||
|
||||
// weight this change
|
||||
const float prob1 = K::NormalDistribution::getProbability(0, HEADING_ALLOWED_SIGMA, diffRad);
|
||||
const float prob1 = Distribution::Normal<float>::getProbability(0, HEADING_ALLOWED_SIGMA, diffRad);
|
||||
|
||||
|
||||
// distance from average? and previous distance from average
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "../../geo/Heading.h"
|
||||
#include "../Grid.h"
|
||||
|
||||
#include <KLib/math/distribution/Normal.h>
|
||||
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
|
||||
#include "GridWalkState.h"
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
#include "../Grid.h"
|
||||
|
||||
#include "../../math/DrawList.h"
|
||||
#include <KLib/math/distribution/Normal.h>
|
||||
#include <KLib/math/distribution/Exponential.h>
|
||||
|
||||
#include "../../math/Distributions.h"
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
|
||||
#include "GridWalkState.h"
|
||||
@@ -55,11 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// https://de.wikipedia.org/wiki/Logistische_Verteilung
|
||||
/** alpha = move the center, beta = slope */
|
||||
const float logisticDist(const float x, const float alpha, const float beta) {
|
||||
return 1 / (1 + std::exp( -((x-alpha)/beta) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// NOTE: allocate >>ONCE<<! otherwise random numbers will NOT work!
|
||||
@@ -83,10 +77,10 @@ private:
|
||||
const float diffRad = potentialHeading.getDiffHalfRAD(cur.heading);
|
||||
|
||||
// weight this change
|
||||
const float prob1 = K::NormalDistribution::getProbability(0, Angle::degToRad(40), diffRad);
|
||||
const float prob1 = Distribution::Normal<float>::getProbability(0, Angle::degToRad(40), diffRad);
|
||||
|
||||
// add the node's importance factor into the calculation
|
||||
const float prob2 = logisticDist(neighbor.imp, 1.0, 0.05);
|
||||
const float prob2 = Distribution::Logistic<float>::getCDF(neighbor.imp, 1.0, 0.05);
|
||||
//const float prob2 = std::pow(neighbor.imp, 10);
|
||||
|
||||
// final importance
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../Grid.h"
|
||||
|
||||
#include "../../math/DrawList.h"
|
||||
#include <KLib/math/distribution/Normal.h>
|
||||
#include "../../math/Distributions.h"
|
||||
|
||||
/**
|
||||
* perform walks on the grid based on some sort of weighting
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
const float diff = cur.heading.getDiffHalfRAD(potentialHeading);
|
||||
|
||||
// probability for this direction change?
|
||||
double prob = K::NormalDistribution::getProbability(0, HEADING_DIFF_SIGMA, diff);
|
||||
double prob = Distribution::Normal<float>::getProbability(0, HEADING_DIFF_SIGMA, diff);
|
||||
|
||||
// perfer locations reaching the target
|
||||
const double shortening = cur.node->distToTarget - neighbor.distToTarget;
|
||||
|
||||
Reference in New Issue
Block a user