Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

random numbers in DJGPP

This topic is 6905 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

You have to seed the random number generator with your clocks current milliseconds. That should give you a random enough number.

Share this post


Link to post
Share on other sites
Advertisement
you should actually use the rand() function because it's more portable. to get the best possible random numbers (they are never truly random), you have to seed the random number generator every time the program starts. to do this #include . then somewhere at the beginning of your program, insert this: srand(time(NULL)) ;
this will seed the random number generator with the number of seconds (milliseconds maybe?)elapsed since midnight. this way your program will come up with different random number every time you run it.

------------------
-Justin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I know how the random(); function works but it generates the same numbers everytime you compile/run the program. Does anybody know if there is such a randomize() function in DJGPP too and how you could use it since I know DJGPP's Help is talking about initstate(unsigned seed, char *arg_state, int n) but I have no clue how to use that!

Thanks in advance,

-- Paul

Share this post


Link to post
Share on other sites

  • 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!