C# Random Numbers aren't being “random”

后端 未结 5 1658
情歌与酒
情歌与酒 2020-11-28 15:40

I know that the C# Random class does not make \"true random\" numbers, but I\'m coming up with an issue with this code:

    public void autoAttack(enemy theE         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 16:33

    if you generate random numbers in loop it will probably wont be random. because random numbers are basically created internally on current system time. So place this code in the loop:

    Thread.Sleep(10);
    

    So the system will go to sleep for 10 m sec. And you will get new fresh random number. Its a guaranteed solution. But this will also effect to performance of the system.

提交回复
热议问题