Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

random numbers in DJGPP

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 20 December 1999 - 06:48 PM

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


#2 Gromit   Members   

144
Like
Likes
Like

Posted 20 December 1999 - 03:58 AM

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

#3 Just6979   Members   

122
Like
Likes
Like

Posted 20 December 1999 - 06:48 PM

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





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.