I'm not sure that I have used the correct terminology in my headline, but what I'm trying to do here :
I have a light particle class (simplified) for which random behavior is required for birth and wall collision. I want to keep the facilities in the classroom. For my understanding, a stable member is created only once and can be shared in all instances of class.
For the random number generator object, I would like to call the seed method once, but it is uncertain how to do it, because most examples are plain fixed variables or functions Use. Particle: h < Strong> particle. CPP By inserting the seed method in the particle manufacturer I think it is called on every birth particle. The only accelerated hack which I could think was to add a Boole member to the particle orbit, which lies on the first seed call An easy way to do this: create a category named "AutoInitRNG", which is its constructor In the
#include & lt; Random & gt; Class particle (public: particle); private: static std :: default_random_engine pRNG; static std :: uniform_real_distribution
#include "particle.h" #include & lt; ctime & gt; Std :: default_random_engine particle :: pRNG.seed (time) ); // Wrong - help! Particle :: particle () {} // methods, etc.
default_random_engine , there are seeds and make the static member variables of the particle something like this:
No comments:
Post a Comment