Thread: Random Number Generation

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Random Number Generation

    I'm just curious... I know there are already alot of random number generating functions. But when I think about it, it doesn't seem plausable for any program to be random. Seriously out of curiosity, if you were a programmer in the 70's-80's without any idea of how to randomnize, how would you do it? (btw, i know it didn't actually, but in this timeframe c++ exists )

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >if you were a programmer in the 70's-80's without any idea of how to randomnize, how would you do it?
    I'd fake it, just like now.
    My best code is written with the delete key.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    prelude, re-phase that. I almost choked on my coffee.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >prelude, re-phase that. I almost choked on my coffee.

    I would calculate a pseudo-random sequence using a seed supplied by the client code.

    p.s. That's really not much better if you read into it. Anyway, you should know not to drink anything while reading these forums.
    My best code is written with the delete key.

  5. #5
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669
    >if you were a programmer in the 70's-80's without any idea of how to randomnize, how would you do it?
    I'd fake it, just like now.
    prelude, re-phase that. I almost choked on my coffee.
    LMFAO

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>>
    if you were a programmer in the 70's-80's without any idea of how to randomnize, how would you do it?
    <<<

    Cheeky git. What do you mean "had no idea"? Believe it or not, in the 70's and 80's we used exactly the same pseudo-random number genrating techniques as are used today.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669
    >>>
    if you were a programmer in the 70's-80's without any idea of how to randomnize, how would you do it?
    <<<

    Cheeky git. What do you mean "had no idea"? Believe it or not, in the 70's and 80's we used exactly the same pseudo-random number genrating techniques as are used today.
    What I meant by that was being a programmer, with limited access to resources, like the boards, websites, boooks etc.

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Books had been invented then. One such was the manual for your compiler. In those days, when there weren't as many "quick fix" resources, people RTFM and solved their own problems, a skill that seems lost today.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you could also consult that book published in the '60s by the RAND corp. Its this book of 1,000,000 random numbers.

    ill try and find a link, they have it at my uni's library

  10. #10
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ...

    ok, we're getting off topic here... i'm just asking how you would do it, with only the basic programming information resources.

    edit: otherwise known as how do you make fire with two rocks if your living in the wild.

  11. #11
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    droid, I think the idea is already there. You have to "fake it" . Fake randomness with whatever you have available to you. System clock provides you with a number that's always changing so many people used that in addition to other numbers they could pull from various places.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  12. #12
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> i'm just asking how you would do it,

    I've told you how I did do it! I have been programming since 1978 after all.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  13. #13
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Here's a random number generator written in assembly. (don't be deceived by the extension). Might give you an idea of how random number generation works.

  14. #14
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    An example is Solitaire. Most MS version use random numbers based on the system clock. If you press F2 repeatedly in rapid succession, the same game apperas for a second at a time. I would do the exact same thing.

  15. #15
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    For non-cryptography applications Mersenne Twister random number generator is fast,powerful and has an incredibly huge period. There is C code available on the web and a c++ wrapper should take about 15 minutes to write.
    Boost has several PRNG's now and mersenne twister is one of them. Check it out.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. Counting number from a random file
    By kamisama in forum C Programming
    Replies: 42
    Last Post: 02-22-2005, 05:16 PM
  4. non repeating random number generation?
    By gencor45 in forum C# Programming
    Replies: 1
    Last Post: 02-08-2005, 05:23 PM
  5. random number between negative and positive number
    By anomaly in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2003, 08:40 AM