Shop OBEX P1 Docs P2 Docs Learn Events
Mother of all random number generator — Parallax Forums

Mother of all random number generator

Zap-oZap-o Posts: 452
edited 2011-06-08 11:22 in Propeller 1
Has anyone ever heard of or coded in spin, "the mother of all random number generator"?

I am putting together an object for the object exchange that will help a lot of new up and coming programmers on the propeller. It will contain several functions that will be very useful. This is my last function and I am determined to put in the object.

Problem that I am having is its currently written in asm or C++ and I have no expertise in these languages. If someone wants to help and knows C++ please take a look. I need more information on this and figured I would ask here for some help getting started or looking over your code example (if you have done this before).

http://lxnt.info/rng/randomc.htm

or

http://www.agner.org/random/theory/

Comments

  • idbruceidbruce Posts: 6,197
    edited 2011-06-07 06:22
    Zap-o

    I am not sure just how complicated you need this random number generator to be, but here is one that would be simpler to decipher.
    #define getrandom( min, max ) (( rand() % (int)((( max ) + 1 ) - ( min ))) + ( min ))
    

    Bruce
  • Zap-oZap-o Posts: 452
    edited 2011-06-08 08:23
    I am not entirely sure this will work idbruce. I am looking to convert the mother of all random number generator as the site specifies into SPIN. Frankly with all the gamer (hydra) programmers I figured this was going to be a popular topic. Gaming programs need a good random number generator right? Perhaps the reason my object should be worth the effort.
  • idbruceidbruce Posts: 6,197
    edited 2011-06-08 11:22
    @Zap-o - In no way am I suggesting that my function is perfect for your needs, however, one must consider execution speed. Lengthy instructions and computations take time to execute, but you could grab random numbers in a seperate cog before they are needed and supply them when necessary.

    Bruce
Sign In or Register to comment.