gregtour / duck-lang

The Duck Programming Language
http://www.ducklang.org
109 stars 13 forks source link

Added Prototype Random Numbers Library #10

Closed rpcope1 closed 9 years ago

rpcope1 commented 9 years ago

So, this is the prototype random numbers library I've written. Rather than totally rely on the often questionable C rand() built-in, the random number generation is built on XORShift128+, which should provide a excellent quality but fast random number implementation, probably plenty good and fast enough if you're using this to write games (or otherwise). The library implementation is slightly more involved than the math library, hopefully this still looks pretty good. You can play with it via the new example bin/examples/random.txt.

The only thing that's a little sketchy here is some of the ugliness needed to move from fixed width (I'm hesitant to change the actual PRNG implementation away from fixed width) to non-fixed width types (int, long, etc.); still I tested this on both a 32-bit and 64-bit system, and it looks like it works OK on both. Any feedback is highly appreciated, and thanks again for letting me contribute.

Best Regards, Robert

gregtour commented 9 years ago

Great stuff!

rpcope1 commented 9 years ago

Awesome, thanks dude.