Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Random numbers in a loop

Author
Message
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 20th Feb 2009 00:24 Edited at: 20th Feb 2009 00:34
I'm using dbTimer() as the seed, but in a loop it doesn't really change, and this is for AI but when I have like 4 enemies using their own updating methods, they all move (roughly) in sync and only the odd time they move differently from each other. How can I generate a random number in a loop?

edit: nvm, I made it so it doesn't update each AI every frame (only a random number below a certain threshold will update it, and it will also cut down cpu usage).
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 20th Feb 2009 00:37
dbRnd dont remember the c++ equal.

Keep it simple.
Questions? Mail me
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 20th Feb 2009 00:54
rand()? I know how to make the random numbers, but if the seed is too close to the other seed used, the random number will be very close as well, since it is pseudo-random
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 20th Feb 2009 04:54
How about
for extra randomness?

#ifdef _DEBUG
FixBugs(All);
#endif
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th Feb 2009 13:11

To seed the randomness, then use:

to return a random number from 0 to 1

Thats what I use.

Login to post a reply

Server time is: 2024-11-25 15:54:01
Your offset time is: 2024-11-25 15:54:01