Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp BS2P - Random — Parallax Forums

Basic Stamp BS2P - Random

CreativeCreative Posts: 11
edited 2005-10-10 13:17 in BASIC Stamp
Hi, I would like to have more details on the software. For the random function, does it only reach the limit of pseudo randomization meaning it would only generate a fixed sequence rather then having a intelligent output results of random sequence. If so, is there other way where i could generate this function and can the seed value be randomize?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-10 04:35
    The RANDOM function uses an LFSR (linear feedback shift register). What you can do is tumble the seed in a loop until some even takes place (at a random time) that then causes the random value to put to use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • CreativeCreative Posts: 11
    edited 2005-10-10 06:20
    can you show us an example? i don't quite what you meant?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-10 13:17
    Like this:

    Main:
    · DO
    ··· RANDOM lottery
    · LOOP UNTIL (Trigger = Yes)
    ·
    · delay = lottery // 11 + 10


    This little snippet tumbles the RANDOM function until the trigger input is activated -- after that the now random value is used to create a delay between 10 and 20 units.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.