refactored random subsystem

added compile-time seed support
This commit is contained in:
2016-04-26 15:15:28 +02:00
parent 8f6bfa917f
commit 62d8d6b36b
17 changed files with 163 additions and 29 deletions

View File

@@ -6,6 +6,7 @@
#include "../../math/DrawList.h"
#include "../../math/Distributions.h"
#include "../../math/DrawList.h"
#include "../../nav/dijkstra/Dijkstra.h"
@@ -34,7 +35,7 @@ private:
DrawList<T&> drawer;
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -23,7 +23,7 @@ private:
static constexpr float HEADING_CHANGE_SIGMA = Angle::degToRad(10);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -8,6 +8,7 @@
#include "../Grid.h"
#include "../../math/DrawList.h"
#include "../../math/Random.h"
#include "../../nav/dijkstra/Dijkstra.h"
#include "GridWalkState.h"
@@ -31,7 +32,7 @@ private:
static constexpr float HEADING_ALLOWED_SIGMA = Angle::degToRad(20);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -4,6 +4,8 @@
#include "../../geo/Heading.h"
#include "../Grid.h"
#include "../../math/Random.h"
#include "../../nav/dijkstra/Dijkstra.h"
#include "GridWalk.h"
@@ -33,7 +35,7 @@ private:
static constexpr float HEADING_CHANGE_SIGMA = Angle::degToRad(10);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -8,6 +8,7 @@
#include "../../math/DrawList.h"
#include "../../math/Distributions.h"
#include "../../nav/dijkstra/Dijkstra.h"
#include "../../math/Random.h"
#include "GridWalk.h"
#include "GridWalkState.h"
@@ -34,7 +35,7 @@ private:
static constexpr float HEADING_CHANGE_SIGMA = Angle::degToRad(10);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -7,6 +7,7 @@
#include "../../math/Distributions.h"
#include "../../math/DrawList.h"
#include "../../math/Random.h"
#include "../../nav/dijkstra/Dijkstra.h"
#include "../../nav/dijkstra/DijkstraPath.h"
@@ -17,6 +18,8 @@
#include "GridWalkHelper.h"
#include "GridWalk.h"
#include <KLib/math/statistics/Statistics.h>
template <typename T> class GridWalkShortestPathControl : public GridWalk<T> {
@@ -76,7 +79,7 @@ protected:
static constexpr float HEADING_CHANGE_SIGMA = Angle::degToRad(10);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -8,6 +8,7 @@
#include "../../math/Distributions.h"
#include "../../math/DrawList.h"
#include "../../math/Random.h"
#include "GridWalkState.h"
#include "GridWalkHelper.h"
@@ -23,7 +24,7 @@ private:
static constexpr float HEADING_CHANGE_SIGMA = Angle::degToRad(10);
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -6,6 +6,7 @@
#include "../../math/DrawList.h"
#include "../../math/Distributions.h"
#include "../../math/DrawList.h"
/**
* perform walks on the grid based on some sort of weighting
@@ -38,7 +39,7 @@ private:
DrawList<T&> drawer;
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -5,7 +5,9 @@
#include "../Grid.h"
#include "../../math/DrawList.h"
#include <KLib/math/distribution/Normal.h>
#include "../../math/Random.h"
//#include <KLib/math/distribution/Normal.h>
/**
* perform walks on the grid based on some sort of weighting
@@ -38,7 +40,7 @@ private:
DrawList<T&> drawer;
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);

View File

@@ -5,7 +5,9 @@
#include "../Grid.h"
#include "../../math/DrawList.h"
#include <KLib/math/distribution/Normal.h>
#include "../../math/Random.h"
//#include <KLib/math/distribution/Normal.h>
/**
* perform walks on the grid based on some sort of weighting
@@ -38,7 +40,7 @@ private:
DrawList<T&> drawer;
/** fast random-number-generator */
std::minstd_rand gen;
RandomGenerator gen;
/** 0-mean normal distribution */
std::normal_distribution<float> headingChangeDist = std::normal_distribution<float>(0.0, HEADING_CHANGE_SIGMA);