Talk:Random Numbers

From TDN


Contents


RNG Article Reformated

Morning all (yes it's always morning on the Internet!),

This article was previously presented as a "Question/Answer". I reformatted to appear more like an objective reference article. Also re-added in Melv's warning that these algos. might not be perfect in all cases. It is plenty relevant to the page, and Melv is respected authority in the Torque Community.

I added in stubs, where someone can post short tutorials and example-code of the correct way to use the RNG's in torque. When someone wants a random number, they don't want to spend two hours reading uncommented source trying to figure out how the hell it works, they want to call rand() and move on with their live. Personally I just spent several days tracking down a bug where the program only crashed in "RELEASE" mode, because the RNG was seeding it'self to '0', and i still don't know why...

Stuff to include here is:

- Which RNG is preferable and in what circumstances should one be used over the other?
- Is there a global RNG object already or do we need to create our own every time?
- What is the proper way to instantiate the RNG in Torque, does it need to be seeded, if so how?
- What is the proper way to grab a new random number?
- What if I want a pseudo-random sequence that is the same everytime the program is run?
- What if I want a truly random sequence that is NOT the same every time the program is run?

Finally I have reformatted and added some comments into the actual source code. Can't spend more time on this now, and still don't fully understand how it works myself. Perhaps someone else can pickup where I left off though and finish the job. I will figure out who is maintaining the official Torque Docs these days and email them copies of my source, maybe it will make it into the next doxygen or official Torque release.

--Steven Peterson 23:58, 8 October 2008 (PST)

Reply 1

(stub)

Reply 2

(stub) ...