Issues with seeding a pseudo-random number generator more than once?

前端 未结 4 1931
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 21:57

I\'ve seen quite a few recommendations for not seeding pseudo-random number generators more than once per execution, but never accompanied by a thorough explanation. Of cour

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 22:18

    Well it's extra processing that doesn't need to be done.

    In that scenario I'd just call the constructor once with a time-based seed before the start of the loop. That will guarantee random results without the extra overhead of changing seeds for every iteration.

    I wouldn't think your method is any more random than that.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题