Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace percent with something more credible #1

Open
semibran opened this issue May 31, 2017 · 2 comments
Open

Replace percent with something more credible #1

semibran opened this issue May 31, 2017 · 2 comments

Comments

@semibran
Copy link
Owner

The current implementation of percent happens to be copied from a certain answer on StackOverflow.

function percent(seed) {
  var x = sin(seed) * 0xFFFFFF
  return x - floor(x)
}

While this algorithm is quite fast and works well for small projects, it'd be great to see this function replaced with something more credible (i.e. some PRNG with its own Wikipedia article).

@jamen
Copy link
Contributor

jamen commented Apr 25, 2018

There is Mersenne Twister which is a "a well tested and fairly robust RNG with a huge orbit and excellent performance" (according to this SO post), but the algorithm in the article went over my head. 😩

@jamen
Copy link
Contributor

jamen commented Apr 25, 2018

Another interesting one mentioned is Lehmer RNG which looks simple to implement. Maybe even using Emscripten? 😮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants