What is a good random number generator for a game?

前端 未结 16 1621
渐次进展
渐次进展 2020-12-02 04:26

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. P
16条回答
  •  广开言路
    2020-12-02 05:20

    Mersenne Twister is typical in the industry, especially since it lends itself well to SIMD and can be made super fast. Knuth is popular too (thanks, David).

    In most game applications speed is really the critical factor, since players are going to complain about low framerate a lot more than they will complain about the fact that there is a slight bias towards generating a 3 whenever it is preceded by a 7, 2, and 9 in that order.

    The exception of course is gambling for money, but there your relevant licensing authority will specifically lay out the algorithms that you can use.

提交回复
热议问题