Shop OBEX P1 Docs P2 Docs Learn Events
random number — Parallax Forums

random number

ArchiverArchiver Posts: 46,084
edited 2000-10-19 05:45 in General Discussion
Hello: A few weeks back somebody asked how to generate a random number
without an input state as a seed. I missed the answer,or deleted it by mistake.
How can this be done? I have a robot that wanders around. I want him to
randomly start seeking light,but dont have any physical switch inputs. I do
have bumper switchs and IR detectors.Could I store some seed value from a
bumper detection,and then use it at a later date?
Thanks all
Sincerely
Kerry
Admin@M...
WWW server hosting
[url=Http://mntnweb.com]Http://mntnweb.com[/url]
Binghamton online Webcam [url=Http://MntnWeb.Com/bing.htm]Http://MntnWeb.Com/bing.htm[/url]
CHRISTMAS Web Page [url=Http://mntnweb.com/xmas.htm]Http://mntnweb.com/xmas.htm[/url]
--So you think you need more memory... the LEM went to the moon on 16K,how
much do you REALLY need?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-18 18:28
    At 12:51 PM 10/18/00 -0400, you wrote:
    >Hello: A few weeks back somebody asked how to generate a random number
    >without an input state as a seed. I missed the answer,or deleted it by
    >mistake.
    >How can this be done? I have a robot that wanders around. I want him to
    >randomly start seeking light,but dont have any physical switch inputs. I do
    >have bumper switchs and IR detectors.Could I store some seed value from a
    >bumper detection,and then use it at a later date?

    Why not just have an incremental counter... ie N=N+1 : If N > 1000 then N=0
    Only when you detect a BUMP, the value of "N" becomes a seed value...ie
    If {BUMP=TRUE or FALSE} then SEED = N


    >Thanks all
    >Sincerely
    >Kerry
    >Admin@M...
    >WWW server hosting
    >[url=Http://mntnweb.com]Http://mntnweb.com[/url]
    >Binghamton online Webcam [url=Http://MntnWeb.Com/bing.htm]Http://MntnWeb.Com/bing.htm[/url]
    >CHRISTMAS Web Page [url=Http://mntnweb.com/xmas.htm]Http://mntnweb.com/xmas.htm[/url]
    >--So you think you need more memory... the LEM went to the moon on 16K,how
    >much do you REALLY need?

    Beau Schwabe IC Mask Designer
    National Semiconductor Network Products Division
    500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-19 05:45
    > Hello: A few weeks back somebody asked how to generate a random number
    > without an input state as a seed. I missed the answer,or deleted it by
    mistake.
    > How can this be done? I have a robot that wanders around. I want him to
    > randomly start seeking light,but dont have any physical switch inputs. I
    do
    > have bumper switchs and IR detectors.Could I store some seed value from a
    > bumper detection,and then use it at a later date?

    Hi Kerry,


    One way to generate a random seed on the stamp is to use the RCtime
    command. This works best if you have a pin set up with a long time delay
    that will return an RCtime value of 10000 or more. Due to noise on the
    power supply, the value fluctuates from reading to reading, the random
    seed.

    If you have digitized light levels from the robot eyes, just use those as
    your random seed.

    Be sure not to use zero as a seed!

    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
Sign In or Register to comment.