<legend id='TKd4w'><style id='TKd4w'><dir id='TKd4w'><q id='TKd4w'></q></dir></style></legend>

<small id='TKd4w'></small><noframes id='TKd4w'>

<tfoot id='TKd4w'></tfoot>
    <bdo id='TKd4w'></bdo><ul id='TKd4w'></ul>
    1. <i id='TKd4w'><tr id='TKd4w'><dt id='TKd4w'><q id='TKd4w'><span id='TKd4w'><b id='TKd4w'><form id='TKd4w'><ins id='TKd4w'></ins><ul id='TKd4w'></ul><sub id='TKd4w'></sub></form><legend id='TKd4w'></legend><bdo id='TKd4w'><pre id='TKd4w'><center id='TKd4w'></center></pre></bdo></b><th id='TKd4w'></th></span></q></dt></tr></i><div id='TKd4w'><tfoot id='TKd4w'></tfoot><dl id='TKd4w'><fieldset id='TKd4w'></fieldset></dl></div>

      1. 什么是游戏的好的随机数生成器?

        时间:2023-10-07

          <bdo id='hYRvb'></bdo><ul id='hYRvb'></ul>
        • <tfoot id='hYRvb'></tfoot>
              <tbody id='hYRvb'></tbody>

                  <legend id='hYRvb'><style id='hYRvb'><dir id='hYRvb'><q id='hYRvb'></q></dir></style></legend>

                  <i id='hYRvb'><tr id='hYRvb'><dt id='hYRvb'><q id='hYRvb'><span id='hYRvb'><b id='hYRvb'><form id='hYRvb'><ins id='hYRvb'></ins><ul id='hYRvb'></ul><sub id='hYRvb'></sub></form><legend id='hYRvb'></legend><bdo id='hYRvb'><pre id='hYRvb'><center id='hYRvb'></center></pre></bdo></b><th id='hYRvb'></th></span></q></dt></tr></i><div id='hYRvb'><tfoot id='hYRvb'></tfoot><dl id='hYRvb'><fieldset id='hYRvb'></fieldset></dl></div>

                  <small id='hYRvb'></small><noframes id='hYRvb'>

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

                  问题描述

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

                  我的考虑是:

                  1. 需要大量随机数,所以速度不错.
                  2. 玩家总是会抱怨随机数,但我希望能够向他们指出一个参考资料,说明我确实做到了我的工作.
                  3. 由于这是一个我没有太多时间参与的商业项目,如果算法 a) 相对容易实现或 b) 有一个很好的非 GPL 实现可用,那就太好了.
                  4. 我已经在很多地方使用了 rand(),所以任何其他生成器最好能证明它需要的所有更改是合理的.

                  我对这个主题不太了解,所以我能想到的唯一选择是 Mersenne捻线机;它是否满足所有这些要求?还有什么更好的吗?

                  Mersenne Twister 似乎是共识选择.但是第 4 点呢?它真的比 rand() 好很多吗?

                  编辑 2: 让我更清楚地说明第 2 点:玩家无法通过知道随机数来作弊.时期.我希望它足够随机,以至于人们(至少那些了解随机性的人)不会抱怨它,但我并不担心预测.这就是为什么我把速度作为首要考虑因素.

                  编辑 3:我现在倾向于 Marsaglia RNG,但我仍然希望获得更多的输入.因此,我正在设置赏金.

                  编辑 4: 请注意:我打算在今天 UTC 午夜之前接受一个答案(以避免弄乱某人的代表上限).因此,如果您正在考虑回答,请不要等到最后一刻!
                  另外,我喜欢 Marsaglia 的 XORshift 生成器的外观.有人对他们有任何意见吗?

                  解决方案

                  George Marsaglia 有开发了一些目前可用的最好和最快的 RNGMultiply-with-carry 是一个值得注意的均匀分布.>

                  === 更新 2018-09-12 ===

                  对于我自己的工作,我现在使用 Xoshiro256**,这是对 Marsaglia 的 XorShift 的一种进化/更新.

                  === 更新 2021-02-23 ===

                  在 .NET 6(目前为预览版)中,System.Random 的实现已更改为使用 xoshiro256**,但仅适用于无参数构造函数.采用种子的构造函数使用旧的 PRNG 以保持向后兼容性.有关详细信息,请参阅提高随机性(性能、API 等)

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

                  My considerations are:

                  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.

                  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?

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

                  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.

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

                  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 has developed some of the best and fastest RNGs currently available Multiply-with-carry being a notable one for a uniform distribution.

                  === Update 2018-09-12 ===

                  For my own work I'm now using Xoshiro256**, which is a sort of evolution/update on Marsaglia's XorShift.

                  === Update 2021-02-23 ===

                  In .NET 6 (currently in preview) the implementation of System.Random has been changed to use xoshiro256**, but only for the parameterless constructor. The constructor that takes a seed uses the old PRNG in order to maintain backwards compatibility. For more info see Improve Random (performance, APIs, ...)

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

                  上一篇:用于从每个元素具有不同概率的列表中进行选择 下一篇:需要一个快速的 C++ 随机生成器

                  相关文章

                  最新文章

                1. <legend id='TVfXL'><style id='TVfXL'><dir id='TVfXL'><q id='TVfXL'></q></dir></style></legend>
                      <bdo id='TVfXL'></bdo><ul id='TVfXL'></ul>
                    <tfoot id='TVfXL'></tfoot>

                    1. <small id='TVfXL'></small><noframes id='TVfXL'>

                    2. <i id='TVfXL'><tr id='TVfXL'><dt id='TVfXL'><q id='TVfXL'><span id='TVfXL'><b id='TVfXL'><form id='TVfXL'><ins id='TVfXL'></ins><ul id='TVfXL'></ul><sub id='TVfXL'></sub></form><legend id='TVfXL'></legend><bdo id='TVfXL'><pre id='TVfXL'><center id='TVfXL'></center></pre></bdo></b><th id='TVfXL'></th></span></q></dt></tr></i><div id='TVfXL'><tfoot id='TVfXL'></tfoot><dl id='TVfXL'><fieldset id='TVfXL'></fieldset></dl></div>