mercredi 18 janvier 2017

Random Number generation missing a pattern for the same seed

I am generating a random number for a particular seed ...So I have property called "seed" which I allow the user to set . I give him two options reset and trigger . The reset will re start the generation of random numbers . And trigger will generate the next random number . The pseudo code is somewhat like

::setSeed( unsigned &  seed )
{
   m_seed = seed
}

::reset()
{
   m_seed = getcurrentseed()
   srand(m_seed);
}

::trigger()
{
    raValue = rand() % minValue + ( rand() % (maxValue-minValue+1) );
}

For a particular seed if I generate say 5 random values 5 times ..sometimes I see a value missing in one of the sets . What could be the reason ?




Aucun commentaire:

Enregistrer un commentaire