Jump to content

Rand()


GoodVibe

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.