Mersenne Twister PRNG.

Previous topic - Next topic

Hatonastick

The Mersenne Twister pseudo random number generator integrated into GLBasic via INLINE.  Except for the squashing of any bugs found, I consider this finished.  So there will be no further updates other than bug fixes.  Enjoy!

Updated 17/02/2009 (3 times today actually):  There have been numerous changes.
Updated 24/02/2009: Very minor change and updated contact information.

Note: This is now included as an attachment as the code (due to the 1000 official test numbers I'm guessing) is now larger than this board allows in a message.

[attachment deleted by admin]

Moru

Confirmed working on GP2X F100 :-) Nice job!

Hatonastick

#2
Glad to hear it. :)

Due to my account recreation I have no control over the original post, so am posting the slightly updated version here.  When I say updated the source hasn't changed (other than minor neatening up), just that it now has a separate document as the comments etc. have been moved from inside the source code to a PDF file.  Unfortunately the PDF has greatly increased the file size. :)

Edit: Just updated the PDF a little.  No other changes from the previous version posted in this post.

Edit: Ok updated the documentation, added the info from Ocean and changed the name of the init functions to something that they should have been in the first place ie. MTSeed and MTArraySeed.  Otherwise it's the same code and not worth re-downloading if you already have it.

[attachment deleted by admin]
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Hatonastick

Thanks mate, all added to the documentation. :)

I've really got to stop working utilities and libraries (current one is a crypto library which still needs a LOT of work) and start working on a game before I go crazy.
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Hatonastick

Oh I think I find them more interesting to make too, but for some reason I still have a burning desire to make games even though I've never finished one (and yet have finished many libraries and utilities).  I think the reason why a MUD is the closest I've ever gotten is that for the most part it feels like you are coding a utility. :blink:
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Hatonastick

Ok thanks for that Ocean.
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

Marmor

generate this code on all plattforms the same rnd() at first ??

Moebius

#7
It was 'RND()' not 'MD()'  ;)  I read as md() first as well....
Marmor: Have you seeded it like in the example?  GLB gives RND a starting point internally when you run the program, but you need to do it yourself with this library.

Anyway, very nicely done Hatonastick!

It seems to be more than 50X FASTER than GLB's RND on my PC!   :O
Does anyone else get similar results?
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Moebius

Confirmed working on iOS for me  =D
Again the Mersenne Twister PRNG is faster than GLB's RND by a factor of 50!
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

Yes. My RND is a very complex one, that does a very good job to give really random numbers. Like: there must be a chance that the same number is generated 3x in a row, as well as one number never being picked at all...

Moebius

Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary