0
Could you put a rand for the seed inside of a srand? Like this maybe? srand ( rand () );
or would this result fail?
2 Answers
+ 8
Yes you could do it, but since rand will always return the same value as it has the same starting point, it won't be any better than not calling srand.
+ 2
Just to expand on John Wells post, think about RNG. We use an algorithm. That's constant. Any number produced will have a predictable outcome, even if we've 100 algorithms, because we're limited to a constant set of numbers along the line.
Solution: use something dynamic as a seed. There are many possibilities like temperature, humidity, radio waves, even user input, but the most pragmatic is time because it requires no extra sensory hardware or human input. That's why we use time: it is constantly changing, ensuring a different seed each run.
*I am aware of how in specialised cases RNG using a time seed alone may be somewhat predictable and some of the metrics which mitigate this.