MWC Random Number Generator

Xibalba Studios Corona Plugins / Utility


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.

Additional information

Apr 03 2018

Sep 01 2015


Initial version

Get documentation