Mersenne Twist Random Number Generator
Blitz3D Forums/Blitz3D Userlibs/Mersenne Twist Random Number Generator
| ||
For those that know why you want consistant pseudo random numbers out of your random number generator... http://www.obsidianobelisk.com/software/mtuserlib.zip Just the decls file and dll... Commands: SeedRand(seed%) - seed the random number generator x% = Rand32() - return the next number in PRNG x% = RandMax(max%) - return random number from 1 - max x% = RandRange(lo%, hi%) - return random number from lo - hi |
| ||
Oh... It was made from some freeware C conversion I found floating around on the net. I tweaked it a bit to create a dll and work with blitz, but other than that... |
| ||
Tests indicate it to work well across CPUs... Despite Mark's protestations to the contrary. So there you go... http://www.obsidianobelisk.com/software/randtest.zip That file contains the source and executable for a program that will test with a predetermined seed value a sequence of 200,000 numbers. All tests so far have resulted in "MATCH". If you wish to test the PRNG, just put the dll in the same directory as the randtest.exe program and run it. If ANYONE gets "FAILED" I would like to know what CPU they are running. I'll post in the blitz+ forums as well, and I'll convert it to a blitzmax module in short order. Kanati |
| ||
Kanati - can you add this to the Toolbox? |