Jump to content
  • Advertisement
Sign in to follow this  
jimmySmile

problem with random

This topic is 3560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all... I'm working with a random function, the problem is when I use seconds as my random seed... In my game I need to call the random function 15 times consecutively, the computer is so damn quick with these calculations so that random seed (seconds) is similar for all of the 15 random functions (which cause for the same numbers to be generated). any ideas how to solve that??

Share this post


Link to post
Share on other sites
Advertisement
usually, you only seed your random number generator once, at the beginning of the program. Then each time you call random, you'll get a different value.

Share this post


Link to post
Share on other sites
Quote:
Original post by jimmySmile
Hi all...
I'm working with a random function, the problem is when I use seconds as my random seed... In my game I need to call the random function 15 times consecutively, the computer is so damn quick with these calculations so that random seed (seconds) is similar for all of the 15 random functions (which cause for the same numbers to be generated).

any ideas how to solve that??


The reason it's called a random "seed" is that you only have to plant it once, and then pick as many random numbers as you like off the resulting tree. If you plant several genetically identical seeds, and pick the first number off each tree, you can hardly be surprised when they're all the same. (Of course, sometimes it's useful to be able to reproduce a series of random numbers, for example to verify a random simulation.)

Except that "plant" and "tree" aren't technical terms here the way that "seed" is. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!