I need a Random Number Generator that produces same sequence of numbers both in iOS and Android if we give the same Seed in both.
I tried the rand() function with the srand(1000). But it gave different outputs.
Then I tried mersenne twister. But that too gave difference sequence for same seed.
Could any one please help me on this.
I am using cocos2d-x for my development.
I have adapted an online CRandomMersenne library and I am really sorry I can no longer find the source for that one. But here is my Mersenne Twister implementation:
Usage of the above class is quite simple:
I have tested this many times and it performs better and faster than most random number generators I have seen.
A lot of times I have relied on the fact that it is deterministic given a seed so you can use it I guess. I will try to find the original source for that code and give the credit to the author.
EDIT: author of the code above is Agner Fog and on his website there is a whole section for random number generators. All credit for the code goes to him.