Re: Enchanted Forest (I and II)
Sam, on host 24.61.194.240
Monday, July 8, 2002, at 05:01:46
Re: Enchanted Forest (I and II) posted by gremlinn on Saturday, July 6, 2002, at 11:29:27:
> So I think what happened, if I remember what Sam said, is that the random seed which generated the map just happened to coincide with the one which had been used earlier in the day. I have no idea how unlikely this is, but it's maybe not too far out there.
The random number seed is time(0) + getpid(), which is the number of seconds since January 1, 1970, added to the internal process ID of CGI hit in which a new board is generated. I *think* UNIX process IDs fall in the range of 1-32768. They are allocated sequentially, wrapping around and skipping process IDs still in use. So five processes fired off in a row will probably have consecutive process IDs. There are usually a few hundred processes running on the system at any given time: some of these are fly-by-night processes that disappear as quickly as they appear, while others are daemons -- things like the web server and telnet sessions and so forth -- that stick around for long periods of time, some even from the moment the machine is booted until it is shut down.
At any rate, if you fire up a game of EF exactly 30000 seconds after your previous one, and the process ID you get is exactly 30000 less than the previous one, then you'll get the same game layout. Everything that's randomized *during* the game will be different, but everything generated initially will be the same.
Obviously this is a pretty highly unlikely occurrence. I'll leave it to you to calculate some estimates on its probability.
In any event, the window of opportunity for firing up a repeat game ends after 32768 seconds.
|