Cool quote picking can freeze when hardware random number generation is not working
[alexxy/gromacs.git] / src / gromacs / utility / coolstuff.cpp
index 3f42a264f0a555fd0578e4e0131f2a4bc4c297d2..55c80cd1cda56f5fe4007a687965f3e7fb6585e1 100644 (file)
@@ -74,9 +74,9 @@ bool beCool()
 
 //! Return a valid random index into \c arrayRef
 template<typename T>
-const T& getRandomElement(gmx::ArrayRef<const T> arrayRef)
+const T& getPseudoRandomElement(gmx::ArrayRef<const T> arrayRef)
 {
-    std::random_device                    generator;
+    std::mt19937_64                       generator;
     std::uniform_int_distribution<size_t> distribution(0, arrayRef.size() - 1);
     return arrayRef[distribution(generator)];
 }
@@ -116,7 +116,7 @@ std::string bromacs()
 
     if (beCool())
     {
-        return getRandomElement<const char*>(bromacsArray);
+        return getPseudoRandomElement<const char*>(bromacsArray);
     }
     else
     {
@@ -1586,7 +1586,7 @@ std::string getCoolQuote()
 
     if (beCool())
     {
-        auto quote = getRandomElement<Quote>(quoteArray);
+        auto quote = getPseudoRandomElement<Quote>(quoteArray);
         return formatString("GROMACS reminds you: \"%s\" (%s)", quote.text, quote.author);
     }
     else