#random number generators
1 messages · Page 1 of 1 (latest)
Please help
I dont understand what they mean by "created and seeded everytime"
it means that everytime the function is called, the pseudo-random number generator also generates new number, so to fix it you can create a global boolean variable to mark it whether the function is already ever called or not, if it is, then don't run the generator again, otherwise run
bool called = False;
int getCard()
{
if (!called)
{
called = true;
std::mt19937 mt{std::random_device{}() };
std::uniform_int_distribution card{ 1, 52 };
return card(mt);
}
}
Which one is the seeding part ?@fervent tangle
random_device
just like the description in the image you sent
So random device gets created and seeded?@fervent tangle
yes
What does being seeded mean jn dummy terms?@fervent tangle
seed means a list of number the generator can generate, and we usually assign a number to the generator to tell it what seed number we want
for example seed 1 is 1-10
seed 2 is 11-20
and so on
we seed also cuz for the list of numbers generated will be the same, without a seed number, the list of number generated will be random
Which one is the generator here?@fervent tangle
uniform_int_distribution
Only tht thing represents generator?@fervent tangle
yes
So herein this image whats the seed number??@fervent tangle
idk
There is no seed in that image, it is set somewhere in the random_device() function probably
But they say this get seeded everytine the function is called @grizzled badger
thats is not really true
a seed is not a list of numbers the computer can generatr
a seed is like a base number used to generate numbers
it can be any numbers like 474994947389474
usually people use something like thr current time of the system, since it changes all the time its a good way to ensure your generates numbers will not be the same
Man I'm tryns know what seed is i still don't have an idea ,what is it?@grizzled badger
any number used as a base to generate other numbers
Base like? Exponents?
have you ever play minecraft? its the same thing, each world is based on a seed
No I haven't
@grizzled badger can you please show example