Initialize random numbers generator

Understanding the language, error messages, etc.

Re: Initialize random numbers generator

Postby 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.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Initialize random numbers generator

Postby FreddyBoubil » Thu May 22, 2014 3:24 pm

Image
FreddyBoubil
 
Posts: 9
Joined: Fri Mar 28, 2014 1:49 pm
Location: France

Re: Initialize random numbers generator

Postby 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:
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).
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Initialize random numbers generator

Postby FreddyBoubil » Fri Jun 20, 2014 8:40 am

Just saw this, thanks a lot !
FreddyBoubil
 
Posts: 9
Joined: Fri Mar 28, 2014 1:49 pm
Location: France

Re: Initialize random numbers generator

Postby EvangelineChen » Fri Oct 06, 2017 5:31 pm

You can try portable generators because using best portable generator is the best option generatorsideas.com
EvangelineChen
 
Posts: 1
Joined: Fri Oct 06, 2017 5:28 pm

Previous

Return to Programming Questions

Who is online

Users browsing this forum: Google [Bot] and 16 guests

cron