Answer the question
In order to leave comments, you need to log in
What does time mean when using this class?
What up, programmer.
when generating random numbers, classes from the boost library are used (Correct me if I'm wrong)
Here is the code
mt19937 randomGenerator (time(NULL);
uniform_int_distribution attackRoll(1, 9);
Those who rummage around will understand this code easily. So, please explain in simple terms, what does time mean here, its parameter is NULL and stuff like that.
Answer the question
In order to leave comments, you need to log in
mersenne_twister_engine - here is the mt19937 class itself (now it is already in std, so it's not a fact that the boost is used), here is its constructor: mersenne_twister_engine/mersenne_twister_engine , here is what they write about its only parameter:
> value - seed value to use in the initialization of the internal
state this is the seed for your random generator. How often this is done in tasks that do not require a high level of security, the current time is taken as the seed.
And here is the time function itself. It takes one parameter, a pointer to time_t, and returns time_t as well. In any case, it will return the current time, if you are in a quality. pass a non-null pointer to the first parameter, then it will also record the current time using it. In your example, NULL is passed, because return value is used.
And here it is - uniform_int_distribution - a class of uniform distribution of a random variable. Most likely, further down the code, it is used in conjunction with a random generator to obtain random values that satisfy this uniform distribution.
Learn to google: www.cplusplus.com/reference/ctime - retrieved from "C time"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question