Temple of The Roguelike Forums
Development => Programming => Topic started by: Krice on December 26, 2008, 05:20:50 PM
-
I heard rand() is not that good and there are better alternatives. What should I use? I want it to be free from any license nonsense. Also, how to make an accurate percentage hit? I think there is a flaw in my percentage random routine, because it's hitting even 2% quite often.
-
I suggest you take a look at the Mersenne Twister (http://en.wikipedia.org/wiki/Mersenne_twister). You can find implementations online for sure :)
-
The C++ source code for MT looks like poop, but I may have to give up quality standards in this case and use it. I don't know the theory to implement one myself. I'm hopeless in math.
-
Heheh, I know. Just treat it like an ordinary lib... make a simple .h file and only import the randomization function.
And the Mersenne Twister generates numbers in a Uniform distribution - there are ways you can transform that into other distributions, like Normal, Poisson, Exponencial, etc. I had that in a math course this semestre, it's pretty cool, and not that hard!