
I'm just starting out with boost, and I'm playing around with the random library. I'm writing a class that is supposed to simulate a six-sided die. It compiles and everything works, except seeding the mt19937. Every time I try testing this class, I get the same numbers, no matter what value I call my seed method with. If I use the constructor that takes a seed value, I get different numbers, but reseeding the object still doesn't seem to have any effect. Any ideas? #include <boost/random.hpp> class D6 { typedef boost::mt19937 engine_t; typedef boost::uniform_int<> dist_t; typedef boost::variate_generator<engine_t, dist_t> gen_t; public: D6() : engine(), six(1, 6), die(engine, six) { } D6(boost::uint32_t s) : engine(s), six(1, 6), die(engine, six) { } int roll() { return die(); } // This method seems to do nothing. void seed(boost::uint32_t s) { engine.seed(s); } private: engine_t engine; dist_t six; gen_t die; };