   Why Are My Random Numbers Not Random?
  I was under the impression I wouldn't have to seed my generator in the following code but all of the random numbers generated are the same.  What's wrong?namespace Engine {namespace Math {static boost::mt19937 randomGenerator;static inline float randomFloat(float min, float max) {    boost::uniform_real<float> distribution(min, max);    boost::variate_generator<boost::mt19937, boost::uniform_real<float>> random(randomGenerator, distribution);    return random();}} //namespace Math} //namespace Engine
  I had this "problem" too. The reason problem is in quotations is that it is clearly a design choice on the part of boost (it is possible you may want to generate more than one random number from an engine state), but it does seem slightly unintuitive.Your "random" variable takes a copy of "randomGenerator" in it's constructor.This copy is then used to generate the random output and is then destructed when "random" is destructed at the end of the function. So "randomGenerator" is never updated with the latest state.What I did, which I'm not entirely sure is the right thing to do, was something like this:static inline float randomFloat(float min, float max) {    boost::uniform_real<float> distribution(min, max);    boost::variate_generator<boost::mt19937, boost::uniform_real<float>> random(randomGenerator, distribution);    float out = random();    randomGenerator = random.engine( );    return out;}But I was hacking at the time to get some University work done on time so I really can't recomend it as an option. It works, but seemed horrible as I was writing it.   ;  Try making the first template argument of variate_generator a reference:boost::variate_generator<boost::mt19937&, boost::uniform_real<float>> random(randomGenerator, distribution);Check out the example in the boost documentation: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_random.html;  diablos_blade: Thanks for explaining :Dsebas: Thank you, that works and makes sense.   ;  learn to write your own functions  D:   ;Quote:Original post by OneThreeThreeSevenlearn to write your own functions  D:Did you have something to contribute to that process?   ;  I don't know about the boost random generator, but random number in general are not random. The old-style random generation (function rand()) has to be initialized with a "random" seed (normally a timestamp), otherwise it will produce the same random numbers. See http://www.cplusplus.com/reference/clibrary/cstdlib/rand/ for details.   ;  I'm surprised no one has posted this yet [grin];Quote:Original post by BrainsawI don't know about the boost random generator, but random number in general are not random. The old-style random generation (function rand()) has to be initialized with a "random" seed (normally a timestamp), otherwise it will produce the same random numbers. See http://www.cplusplus.com/reference/clibrary/cstdlib/rand/ for details.Yes the boost method shown here will generate the same series of numbers everytime the program is run.  That's not an issue for my case though, so I won't bother seeding.