rnd() not so random?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BSOB
    New Member
    • Jul 2006
    • 77

    rnd() not so random?

    ok, we've all used random, and if we've used it enough we've figured out that it is infact a predictable function. and honestly, i was ok with that. until i realized that the rnd function's quazi-frequency happens to be the width of my screen. which happens to be an issue.
    1) does anyone know what im talking about?
    2) does anyone know of a good way to make a random number that doesnt have a steady frequency?

    if people dont know what im talking about:
    make a fullscreen form with borderstyle = 0.

    private sub form_click()
    dim shade as byte
    for y = 0 to screen.height
    for x = 0 to screen.width
    shade = rnd*256
    pset(x,y), rgb(shade,shade ,shade)
    next x
    doevents
    next y
    end sub

    and clean your glasses, they might just be scratched.
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    not sure what I should look for, I saw what looked like a TV with no signal. Have you tried using Randomize (timer) at the beginning of your code?

    Comment

    • Wrycu
      New Member
      • Sep 2006
      • 9

      #3
      Rnd isnt random. Think about it. How could it be? Everything here is coded in. But, as the other person said, if you add Randomize (right before rnd is good), it kills the pattern and the same order the 'random' numbers come up in.

      Comment

      • NSF12345
        New Member
        • Aug 2006
        • 21

        #4
        i got told once that the start random number was based on the time and date of the computer (down to the second) so its hard to get the random sequence to run again, but i have often thought the same, how random IS randomize ona computer? and i find that RANDOMIZE at the start of the code (either on load or on click (which ever u want) it tends to garuntee a random number

        Comment

        • Wrycu
          New Member
          • Sep 2006
          • 9

          #5
          It cant be random. At least, not truely random. It cannot chose which to pick, it has to be coded in. So, it says...
          rnd =
          .1343
          .453342
          .423
          .85654
          .45634
          .1433
          .3453
          etc
          and every time you run it, you get those numbers in that order.
          Randomize makes it more random. I dunno how, it probably has some complex thingy that makes it.. more random. or at least, makes it seem random. and as long as it seems random, who cares if it is?

          Comment

          Working...