什么是一个好的随机数发生器的游戏? [英] What is a good random number generator for a game?

查看:118
本文介绍了什么是一个好的随机数发生器的游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是用于C ++游戏的好随机数字生成器?

What is a good random number generator to use for a game in C++?

我的注意事项是:


  1. 需要很多随机数字,所以速度很快。

  2. 玩家总是抱怨随机数字,但我想点他们的参考,解释了我真的完成了我的工作。

  3. 因为这是一个我没有太多时间的商业项目,所以如果算法a)相对容易实现或者b) GPL实现。

  4. 我已经在很多地方使用了 rand(),所以任何其他生成器

  1. Lots of random numbers are needed, so speed is good.
  2. Players will always complain about random numbers, but I'd like to be able to point them to a reference that explains that I really did my job.
  3. Since this is a commercial project which I don't have much time for, it would be nice if the algorithm either a) was relatively easy to implement or b) had a good non-GPL implementation available.
  4. I'm already using rand() in quite a lot of places, so any other generator had better be good to justify all the changes it would require.

我不太了解这个主题,所以唯一的选择我可以来后者是 Mersenne Twister ;它满足所有这些要求吗?还有什么更好的吗?

I don't know much about this subject, so the only alternative I could come up with is the Mersenne Twister; does it satisfy all these requirements? Is there anything else that's better?

编辑: Mersenne Twister似乎是一致的选择。但是点#4呢?是否真的比 rand()

Mersenne Twister seems to be the consensus choice. But what about point #4? Is it really that much better than rand()?

编辑2:我在第2点有点清楚:玩家没有办法通过知道随机数来欺骗。期。我想让它随机,以至于人们(至少是那些了解随机性的人)不能抱怨,但我不担心预测。
这就是为什么我把速度作为首要考虑。

Edit 2: Let me be a little clearer on point 2: There is no way for players to cheat by knowing the random numbers. Period. I want it random enough that people (at least those who understand randomness) can't complain about it, but I'm not worried about predictions. That's why I put speed as the top consideration.

编辑3:现在我倾向于Marsaglia RNG我仍然想要更多的输入。

Edit 3: I'm leaning toward the Marsaglia RNGs now, but I'd still like more input. Therefore, I'm setting up a bounty.

编辑4:只是一个注意:我打算在午夜UTC UTC之前接受答案(避免混淆某人的rep帽)。所以如果你想回答,不要等到最后一分钟!

此外,我喜欢Marsaglia的XORshift发电机的外观。

Edit 4: Just a note: I intend to accept an answer just before midnight UTC today (to avoid messing with someone's rep cap). So if you're thinking of answering, don't wait until the last minute!
Also, I like the looks of Marsaglia's XORshift generators. Does anyone have any input about them?

推荐答案

George Marsaglia 开发了一些目前可用的最好和最快的RNG
乘以携带是一个值得注意的一个均匀分布。

George Marsaglia has developed some of the best and fastest RNGs currently available Multiply-with-carry being a notable one for a uniform distribution.

这篇关于什么是一个好的随机数发生器的游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆