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.
The most random two-digit number is 37, When groups of people are polled to pick a “random number between 1 and 100”, the most commonly chosen number is 37. The Answer to the Ultimate Question of Life, the Universe, and Everything (“what is 6 times 9”, correct in base 13).
Proof that 17 is the most random number between 1 and 20. - YouTube.
Seventeen is: Described at MIT as 'the least random number', according to the Jargon File. This is supposedly because in a study where respondents were asked to choose a random number from 1 to 20, 17 was the most common choice. This study has been repeated a number of times.
You can just write your own random number generator like this. The quality is low but will suit for most of the purpose.
// RAND_MAX assumed to be 32767.
static unsigned long int next = 1;
void srand(unsigned int seed) { next = seed; }
int rand(void) {
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With