Fix the seeding of PRNG when it is used instead of RG
[alexxy/gromacs.git] / src / gromacs / utility / coolstuff.cpp
index 55c80cd1cda56f5fe4007a687965f3e7fb6585e1..65d438b1b67620386d5156ec34633bba9a2ac6de 100644 (file)
@@ -43,6 +43,8 @@
 
 #include "config.h"
 
+#include <time.h>
+
 #include <random>
 #include <string>
 
@@ -76,7 +78,7 @@ bool beCool()
 template<typename T>
 const T& getPseudoRandomElement(gmx::ArrayRef<const T> arrayRef)
 {
-    std::mt19937_64                       generator;
+    std::mt19937_64                       generator(time(nullptr));
     std::uniform_int_distribution<size_t> distribution(0, arrayRef.size() - 1);
     return arrayRef[distribution(generator)];
 }