Difference between revisions of "RandomLua"

(RandomLua Library)
 
Line 6: Line 6:
 
* Multiply-with-carry [http://en.wikipedia.org/wiki/Multiply-with-carry], probably the best option
 
* Multiply-with-carry [http://en.wikipedia.org/wiki/Multiply-with-carry], probably the best option
 
* Linear congruential generator [http://en.wikipedia.org/wiki/Linear_congruential_generator], fast and, well, it works... kind of.
 
* Linear congruential generator [http://en.wikipedia.org/wiki/Linear_congruential_generator], fast and, well, it works... kind of.
MWC and LGC come with 3 pre-defined parameters.
+
MWC and LCG come with 3 pre-defined parameters.
  
 
Download: [http://love2d.org/forums/viewtopic.php?f=5&t=3424 Original Thread]
 
Download: [http://love2d.org/forums/viewtopic.php?f=5&t=3424 Original Thread]

Revision as of 16:49, 6 April 2012

math.random give different numbers on different platforms. Since I don't intend to compile C code for every platform, I decided to create a Pure Lua Random Generator (probably another one...).

3 algorithms:

  • Mersenne twister [1], very good and slow
  • Multiply-with-carry [2], probably the best option
  • Linear congruential generator [3], fast and, well, it works... kind of.

MWC and LCG come with 3 pre-defined parameters.

Download: Original Thread