Hi,
has anyone been testing the random function in details? I've read the details at http://arduino.cc/en/Reference/Random but still... My issue is, if I start with mix=random(1,7); will the probability of mix=1 and for example mix=4 be the same? So, if there are 6 possible results, will they all have the same probability (in this case 1/6)? Hope you understand my question...
And for in advance... when arduino starts, the "random" sequence is always the same. I was thinking about saving always a different number in onchip eeprom and using it once to generate randomseed, you think it would work?
The intent of random(1, 7) is to give you random numbers from 1 to almost 7, like [1, 2, 3, 4, 5, 6]. Just like playing dice. As with any pseudo-random number generator, it will be as good as the software allows, which isn't perfect, but will be fine for playing games that aren't worth millions of dollars.
Yes, you can use EEPROM to save your place or to reseed the sequence with randomSeed() the next time. Another way to pick a good seed is to require the player to push a button, and to time how long it takes them to do it in milliseconds.
(There is a bug being investigated on some versions of avr-gcc, as well.)
So I will use one write cicle per reset, it should last a while (so...for about 10000 games).
But still I wonder about the mathematical part of this random function, if all resoults [1,2,3,4,5,6] have equal probability. So this will act as a "fair" dice.