What is a good random number generator to use in a C ++ game?
My thoughts:
- It takes a lot of random numbers, so the speed is good.
- Players will always complain about random numbers, but I would like to point them to a link explaining that I really did my job.
- Since this is a commercial project for which I have little time, it would be nice if the algorithm either a) was relatively easy to implement or b) had a good implementation other than the GPL.
- I already use
rand() in quite a few places, so any other generator should be good to justify all the changes it needs.
I am not very versed in this matter, so the only alternative I could come up with is Mersenne Twister ; Does it satisfy all these requirements? Which is even better?
Edit: Mersenne Twister seems to be a consensus choice. But what about point number 4? Is this really much better than rand() ?
Edit 2: Let me be a little clearer in paragraph 2: players are not able to cheat, knowing random numbers. Period. I want it to be random enough so that people (at least those who understand randomness) cannot complain about it, but I'm not worried about the forecasts. That is why I put speed as the main focus.
Edit 3: Now I'm leaning towards the Marsaglia runes, but I still like more info. Therefore, I create generosity.
Edit 4: Note only: I intend to accept the answer before midnight UTC today (so as not to bother with any of the players). Therefore, if you want to answer, do not wait until the last minute! Also, I like the Marsaglia XORshift generators. Does anyone have any information about them?
c ++ performance random
Michael Myers Jun 25 '09 at 23:34 2009-06-25 23:34
source share