A question about randomSeed(), indexing randomness
in
Programming Questions
•
2 years ago
Hey guys,
I was wondering about this one
Although I understand that a seed is used to
initialize a number generator (Wikipedia), a randomSeed basically implies that the random() function is sort of accessing an array of generated numbers in a [i++] kind of way? Or some sort of random(seed).get() function.
As
- randomSeed(1);
- float f = random(10); f = random(10); f = random(10);
- println(f);
Will always return the same number.
It would be nice however if you access the value returned from a n-th time a random() call is made directly, say:
- float f = random(10)[3];
Or at least keep track of n; how many times has random() been called?
Of course you could make your own and do something like:
- float getRandomAtIndex(int index) {
- randomSeed(1);
- for(int i = 0; i < index; i++) {
- float r = random(1);
- }
- return random(1);
- }
But that seems rather silly.
Hmmm?
1