Archived

This topic is now archived and is closed to further replies.

Grat

Randomizing

Recommended Posts

Ive got a problem in my c++ game, with randomizing. basically i seed the randomizer with the time, like this: srand( time ( NULL ) ); This is inside a class function, which is called every game loop. However, it doesnt make the number quite random, because it is clear that the number is slowly going up every game loop. Is there any way to make the number more randomized?

Share this post


Link to post
Share on other sites
The problem is that you call srand() every time. You should call it only once the program starts. Then every time you retrieve a random number with rand() this number should be quite random. if you don''t trust the number generator that much you could add simply events that call srand() with some value, but a) keep it very simple or else it will slow your code down and b) that won''t make the numbers much more random, calling srand() once is as good.
The only other way is to find a generator that you trust, or write one yourself ;-)

Share this post


Link to post
Share on other sites