Mersenne Twist Random Number Generator
BlitzMax Forums/BlitzMax Programming/Mersenne Twist Random Number Generator
| ||
For those that know why you want consistant pseudo random numbers out of your random number generator... www.obsidianobelisk.com/software/mersenne.zip Just copy the directory in the zip to your pub.mods directory and you should be set. There's a text file in the docs subdirectory with the commands available. 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+ and blitz3d (see those forums for the userlib), and reworked it a bit to create the blitzmax module, but other than that... Tests indicate it to work well across CPUs... Despite Mark's protestations to the contrary. So there you go... Kanati [edit] and in case it isn't clear, it's freeware... do with it what you will. Mark... feel free to email me if you want the source so you can fix blitz. |
| ||
Just verified that it works consistently across the mac platform as well now. One seed, one sequence... Just as it should be. I'll be rezipping the module to include the test program in the docs directory, and including the source for recompile. Kanati [edit] reuploaded with source code and fresh lemon scent. |
| ||
Anybody that was whining about random number generation in blitz bother to try this yet? Hate to think all that whining was just hot air... (excepting beaks, gfk and morduun that is... I know they tried it) Kanati |
| ||
Works for me (of course only tested with the seed provided). Mac powerbook g4. This is something I'm personally very interested in, so you've made me happy if this works. |
| ||
I could say something here, but I'll try and constrain myself ;) |
| ||
You've already waited 7 months so constraining yourself a little longer shouldn't be too hard. |
| ||
I think its great! Thanks Kanati! |
| ||
Yeh, I missed this the first time around. Should prove useful. |
| ||
Files gone. Any chance of someone uploading it? |
| ||
http://www.radioactivegamer.com/ They're all here now - he moved them about 8 months ago. |
| ||
Great! Sorry to ask so many questions but how would I install it? |
| ||
When I build my game blitz returns "Compile Error: Can't find interface for module 'pub.mersenne'". Is there something else I have to do? |
| ||
Sounds like you either haven't installed it properly or it was compiled with a previous version of BMax and needs to be compiled. You need to extract it such that the folder called Mersenne.mod ( or whatever it's called ) is in BlitzMax\Mod\Pub.Mod\ If you have to compile it, you may need MinGW. Read about that here : http://www.blitzbasic.com/Community/posts.php?topic=53442 |
| ||
I use a version of this I downloaded a few months ago (not sure if the one here is any different), but I can confirm that it works across platforms/CPUs, as it works a treat across all three of my systems below. Just what I needed for my file encryption. Nice work. |
| ||
Is it possible generate floats with this module. It don't understand C but it looks like it uses longs. |