View Single Post
Old Jul 6th, 2007, 1:41 AM   #2
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Ben.Dougall
Hi guys, new to the forum, plan to contribute here a lot as i get bored at work. Quick question on a Random Generator.
That's as good a reason as any, I suppose. Let me be the first to welcome you to the forums.
Quote:
Originally Posted by Ben.Dougall
I have been using this formula for 4 years during Java development, and works fine for whole number generation. I was just wondering what the best, and most efficent method of doing this would be.
Narue has an excellent article here on using rand(), particularly how to use it effectively, avoiding common pitfalls that often yield sequences that are 'less random'. She also has another article that shows you how to roll your own psuedo-random number generator. This might be necessary if the implementation in your compiler's libraries is poor, or simply because you want to have multiple concurrent generators active. As an example of why you might need multiple generators, imagine a Tetris clone that allowed two-player head-to-head games. By using different generators seeded with the same value, you guarantee neither player gets an advantage by having better pieces (since they both get the same pieces in the same order).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote