Results 1 to 5 of 5

Thread: Random Numbers

  1. #1
    ChimpFace9000
    Guest

    Post Random Numbers

    Are there any tutorials on how to write a random number generator? All ive ever found is code for one, which i can never get to work. But id like to write my own so i can learn to write it better for each situation.

  2. #2
    Zaei
    Guest
    Ok, here is a simple algorithm that will return a psudo random number. First, choose a number, called g1. Double that value, and store it in g2. Choose a seed value, and a value for the maximum number to be returned. The, for each iteration, multiply g1 by g2, and add g2, and store it into seed. Do seed mod max and return that value.

    Hope you understood all of that =).

    Z.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Zaei what are you thinking of?
    g1=5
    g2=10
    seed=42
    max=10
    loop[
    seed=g1*g2+g2 (60)
    ]
    return seed % max
    Last edited by kedaman; Sep 1st, 2001 at 06:33 AM.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Zaei
    Guest
    I know. I looked it over after I posted it, and it doesnt make any sense. I copied out from GPG I. ::shrug::

    Z.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    besides it pseudo not psudo
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width