Archive of the Gamebuino Classic forum (2014-2018), rebuilt from the pages kept by the Wayback Machine: only part of the topics and pages were captured. Read-only. Removal on request: hi@gamebuino.com.
Initialize random numbers generator
rodot Thu May 22, 2014 10:28 am
Mmh, I will include a random seed picker function in the library, that's a good idea.
FreddyBoubil Thu May 22, 2014 3:24 pm
rodot Wed May 28, 2014 5:32 pm
Hey guys,
I just added a new pickRandomSeed() function which should be called just after gb.begin();
It's a mix of the battery voltage, the ambiant light and the time elapsed, which depends on how long does the user take to press 'A' to skip the start menu. It works fine with the emulator.
Here is what it does:
As there is a multiplication of 2 pretty large numbers it should overflow several times and give a random random seed ("random random", haha).
I just added a new pickRandomSeed() function which should be called just after gb.begin();
It's a mix of the battery voltage, the ambiant light and the time elapsed, which depends on how long does the user take to press 'A' to skip the start menu. It works fine with the emulator.
Here is what it does:
- Code: Select all
randomSeed(battery.voltage * ~micros() + backlight.ambientLight + micros());
As there is a multiplication of 2 pretty large numbers it should overflow several times and give a random random seed ("random random", haha).
FreddyBoubil Fri Jun 20, 2014 8:40 am
Just saw this, thanks a lot !
EvangelineChen Fri Oct 06, 2017 5:31 pm
You can try portable generators because using best portable generator is the best option generatorsideas.com