summaryrefslogtreecommitdiffstats
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2017-01-14 23:34:51 -0600
committerFerenc Arn <tagcup@yahoo.com>2017-01-15 19:15:16 -0600
commit4c9004671af455a03acb4e2750b12d62b2b3c917 (patch)
tree92d254eaaed667d6049918e4ac2acd1104d7f89f /core/math/math_funcs.h
parent5dde810aa58d66677afda9cc5c89c052e91348b4 (diff)
downloadredot-engine-4c9004671af455a03acb4e2750b12d62b2b3c917.tar.gz
Replace the existing PRNG (Xorshift31) with (minimal) PCG (XSH-RR variant with 32-bit output, 64-bit state).
PCG is better than many alternatives by many metrics (see www.pcg-random.org) including statistical quality with good speed.
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 8ce59224ff..e81646b1ca 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -31,6 +31,7 @@
#include "typedefs.h"
#include "math_defs.h"
+#include "pcg.h"
#ifndef NO_MATH_H
#include <math.h>
@@ -41,8 +42,8 @@
class Math {
+ static pcg32_random_t default_pcg;
- static uint32_t default_seed;
public:
Math() {} // useless to instance
@@ -150,12 +151,12 @@ public:
}
- static uint32_t rand_from_seed(uint32_t *seed);
+ static uint32_t rand_from_seed(uint64_t *seed);
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
static double stepify(double p_value,double p_step);
- static void seed(uint32_t x=0);
+ static void seed(uint64_t x=0);
static void randomize();
static uint32_t larger_prime(uint32_t p_val);
static double dectime(double p_value,double p_amount, double p_step);