This is a simple, lightweight random number generator, adapted to Lua from some code by the late George Marsaglia (who maintained the famed Diehard test suite, for assessing various random number generators properties). It’s a slight update from the same module in the old Code Exchange.
This is a very lightweight generator, so it’s perfectly fine to maintain lots of instances, say one or more per object in a game. Moreover, each instance can be seeded by the user.
The upshot of this is that multiple random number sequences can be produced, these sequences are reproducible when seeded with the same values, and for that matter can be reproduced on e.g. a per-object basis, since there won’t be contention over one master generator.
Random number requests can be made for either a 32-bit integer or float between 0 and 1.
Furthermore, a math.random()-alike variant is available.
I have read many articles about random number generation.
In our games we have a option to turn on true random number generation. We than get the random sequences from random.org (they generate random numbers using atmospheric noise).
Yes, we use the randomseed(os.time()), that is a standard among all languages I would say.
I read that lua RNG generator is not good, that is way we will try to use this plugin.
Math.random() is a wrapper around the C Library’s rand() function which isn’t that great, but if you’re using random.org(), that’s about as random as you’re going to get.
Between a day of travel yesterday and Christmas today, I only just saw this.
The algorithm’s designer, George Marsaglia, was a pretty big deal in the random number generator community. His diehard suites (“batteries” of tests) were all about evaluating the properties of various generators. I took that as a good recommendation.
That said, it would be more of a happy bonus than the express intent of the plugin, which was to be able to maintain unlimited independent generators that could also be saved and restored.
Dirk Laurie has also ported Bob Jenkins’s ISAAC to Lua, which you might also try, though you’d need to backport if from Lua 5.3.
I’m not familiar with the mwc library, but as long as it’s parameter compatible with math.random, there would be no harm in doing what you’re doing. As a safety, you might want to do:
@ubj3d.android Yes, this ought to work. The only thing to watch out for, if you happen to be require()'ing other modules, is that they might contain lines like this:
local random = math.random
Make sure to swap about math.random() before loading any of these others, or you’ll get mixed generators.
Assuming that’s a direct copy-and-paste, you just used the wrong acronym. m W c, for multiply-with-carry, not mvc (which is something else, but unrelated).
module ‘plugin_mwc’ not found:resource (plugin_mwc.lu) does not exist in archive
no field package.preload[‘plugin_mwc’]
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Plugins/plugin_mwc.lu’
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Plugins/plugin_mwc.lua’
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Resources/Corona/plugin_mwc.lua’
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Plugins/plugin_mwc.dylib’
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Resources/Corona/…/…/Frameworks/CoronaCards.framework/Versions/A/Frameworks/plugin_mwc.dylib’
no file ‘./plugin_mwc.dylib’
no file ‘/Users/ubj3d/Desktop/Ultimate BlackJack Reloaded.app/Contents/Resources/Corona/plugin_mwc.dylib’
Okay, then it might indeed be the issue I mentioned above.
Could you give the hotfix a shot? If that fixes it, I know what’s wrong.
I think the version I finally submitted is on an office computer at the moment (got a bit out of sync amid some connection woes), so it might take me a day or two to have it up. It’s probably only a few lines’ difference, but I just want to be sure I don’t undo anything else. I’ll take this opportunity to clean up my cluttered plugins situation, too.