Use of qsrand, random method that is not random

后端 未结 7 2611
误落风尘
误落风尘 2021-02-19 00:12

I\'m having a strange problem here, and I can\'t manage to find a good explanation to it, so I thought of asking you guys :

Consider the following method :



        
相关标签:
7条回答
  • 2021-02-19 00:49

    Because if you call randomize more than once in a millisecond (which is rather likely at current CPU clock speeds), you are seeding the RNG with the same value. This is guaranteed to produce the same output from the RNG.

    Random-number generators are only meant to be seeded once. Seeding them multiple times does not make the output extra random, and in fact (as you found) may make it much less random.

    0 讨论(0)
提交回复
热议问题