A computer can't create real random numbers just by calculations, which is an issue if you want to have random events in e.g. a video game (thsi is also an issue in cryptography but I won't get into that here).
So, instead of generating so-called true random the computer (and the gamebuino) generates
pseudo-rando. As the name already suggests, this randomness isn't really random, instead it is some carefully modeled function where you put numbers in, somehow like this:
- Code: Select all
x0 = f(seed)
x1 = f(x0)
x2 = f(x1)
etc. so the "random" function feeds off of the previous result. As easily seen, if the seed is the same then the sequence of random numbers that follows is the same, this is why you try to pick an as-random-seed as possible. Possible random sources are things like user-input, as it is e.g. impossible to predict just how many microseconds the user will be on the start-menu screen. Other such sources are the battery voltage and the light sensor. Calling gb.pickRandomSeed() will seed this random number generator with some maths operation of these values (as seen
here).
Now, as the random number generator of the arduino is 32-bit, that means it has a period of 2^32, or 4294967296. That means that you need to generate that many random numbers until they will actually re-occor in the same order, which is quite unlikely (for games!!!). And also picking the random seed can almost guarantee that you will get a different sequence of random numbers every time you run your game.
So, what does that mean to you? If you want to use good random numbers just call gb.pickRandomSeed();
after your gb.titleScreen(); call. (This recomendation is also stated in
the reference)