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

PRNG #59

Open
shakna-israel opened this issue Jan 23, 2018 · 0 comments
Open

PRNG #59

shakna-israel opened this issue Jan 23, 2018 · 0 comments
Milestone

Comments

@shakna-israel
Copy link
Owner

shakna-israel commented Jan 23, 2018

Lua's random isn't that good, it's just a wrapper around C's rand, which can change by platform, and isn't exactly awesome. (Not recommended for use on macOS and FreeBSD).

We could use a do-block to implement a random generator that hides it's seed without having to be OO.

An LCG would be easiest to implement, though Lua 5.1/5.2 would be a bit harder for that.

The Mersenne Twister is a tad better than an LCG, but other Lua implementations have found not using C, and using pure Lua is very slow, which wouldn't be acceptable. (Especially as you can't make SIMD-Mersenne-Twister in pure Lua.)

ChaCha20 is crytographically secure, so much better than others, and there is a pure Lua implementation, but it is quite sizeable to implement considering the size of f.lua so far, and I don't have the expertise to confirm if it is working beyond "seemingly random".

I think the best bet is an LCG, specifically Multiply-With-Carry (MWC), which is the same as FreeBSD libc rand.

@shakna-israel shakna-israel added this to the 1.7.0 milestone Jan 23, 2018
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

1 participant