GoodVibe Posted April 23, 2012 Share Posted April 23, 2012 Hello everybody, I just have a quick question. I am trying to develop a webpage for dice rolling (to use for myself when i play dnd) Now, I know a lot of the random functions is computer languages are not truly random, and thus have some areas that the value will be the result more than others. What would be a good way to try to make it as "random" as possible, or am I just over-thinking it? Quote Link to comment https://forums.phpfreaks.com/topic/261485-rand/ Share on other sites More sharing options...
MMDE Posted April 23, 2012 Share Posted April 23, 2012 mt_rand is usually considered a better than rand Or do you want to write on yourself? I think you are best off with mt_rand alone! Quote Link to comment https://forums.phpfreaks.com/topic/261485-rand/#findComment-1339874 Share on other sites More sharing options...
GoodVibe Posted April 23, 2012 Author Share Posted April 23, 2012 I do not know enough math or PHP to try to write one myself I did not know of the existence of mt_rand(), but when i was researching random number generators I did notice that the one it uses is one of the faster and more "accurate" methods out there. Thank you for the help. Quote Link to comment https://forums.phpfreaks.com/topic/261485-rand/#findComment-1339875 Share on other sites More sharing options...
xyph Posted April 23, 2012 Share Posted April 23, 2012 The only issue with rand() or mt_rand() is that they're not cryptographically secure. Their results tables are generated by a seed, usually involving the date/time in microseconds. For a dice roller, it'll work extremely well. The distribution is as good as you'd need. In any pseudo-random environment, results won't be perfectly even. What you want is over many, many iterations, these numbers are distributed well and no patterns show up for any specific results. Quote Link to comment https://forums.phpfreaks.com/topic/261485-rand/#findComment-1339991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.