Random seed

Hi,

I am trying to generate a new random seed every time my app is run but I
have some constraints:

a) it has to run from a CD-ROM, so it can’t write back to the HD (to
continue a sequence).
b) the SDL_GetTicks() always starts at 0, and the app seems to load all of
its resources in exactly the same amount of time every time (on the same
machine).
c) it needs to generate a seed before the user presses a key. i.e., I can’t
generate one based on user input delay.
d) the mouse position seems to be initialized to 0,0.

Can anyone think of a way without resorting to platform-specific code to get
the system timer?_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

| Can anyone think of a way without resorting to platform-specific code to
| get the system timer?

I use time(NULL) to get the current system time in seconds and use that
as the seed.On Tue, Mar 26, 2002 at 10:50:25PM +0000, Feral Coder wrote:


I am not authorised to fire substitute teachers
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

| Can anyone think of a way without resorting to platform-specific code to
| get the system timer?

I use time(NULL) to get the current system time in seconds and use that
as the seed.

Right, using time() as the seed is pretty much standard practice. The
time() function is ANSI C, so it’s reasonable to expect it on all platforms.
If a platform doesn’t support ANSI C, then you’ll have to resort to platform
specific code anyway probably.

-Jason

----- Original Message -----
From: james@piku.org.uk (James)
To:
Sent: Tuesday, March 26, 2002 6:17 PM
Subject: Re: [SDL] random seed
On Tue, Mar 26, 2002 at 10:50:25PM +0000, Feral Coder wrote:

“Jason Hoffoss” said:

> > On Tue, Mar 26, 2002 at 10:50:25PM +0000, Feral Coder wrote:

| Can anyone think of a way without resorting to platform-specific code to
| get the system timer?

I use time(NULL) to get the current system time in seconds and use that
as the seed.

Right, using time() as the seed is pretty much standard practice. The
time() function is ANSI C, so it’s reasonable to expect it on all platforms.
If a platform doesn’t support ANSI C, then you’ll have to resort to platform
specific code anyway probably.

-Jason

I use srandom(getpid()+time(NULL)); since the app I really explored seeding
with might be called several times in a given second. time(NULL) is pretty
safe and portable shrug I used it on FBSD, Linux, and Windows


-Erik <@Erik_Greenwald> [http://math.smsu.edu/~erik]

The opinions expressed by me are not necessarily opinions. In all probability,
they are random rambling, and to be ignored. Failure to ignore may result in
severe boredom or confusion. Shake well before opening. Keep Refrigerated.