Hello,

I have a question about random numbers in HLA. It appears from running one of my programs that the same sequence of random numbers occur every time it is run. e.g.
4
15
6
7
12
24
etc.

Do I need to set the seed everytime, or why is it always the same number set? The urange.rand numbers are always being stored in eax (which is done anyway by default). I then move the contents of eax into variable "i":


rand.urange(1,25); // pick a random number, 1 through 25
mov(eax,i); // move it into i variable


Any ideas?

I also updated my project "HLA Adventure" with double the rooms, more monsters to fight, and some quests. You can download it at:

http://members.tripod.com/~panks/hlaadv.html

or

http://www.geocities.com/dunric/westfront.html

Sincerely,

Paul Panks
dunric@yahoo.com
Posted on 2003-05-14 03:08:07 by Paul Panks
The random algorithm use the seed to generate the random numbers.
If you initialize the seed with the same number, you will get the same sequence of random numbers.

The thing to do is to initialize the seed with a different value everytime (GetTickCount(), Time, rdtsc, anything relatively "random").
Posted on 2003-05-14 04:23:10 by JCP
Posted on 2003-05-14 04:56:26 by Vortex