[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pbmserv-dev] Change to the random algorithm
To address the "things don't seem too random" complaints, I've instituted
a change to the way pbmserv does random seedings, etc.
BEFORE:
everytime pbmserv started up, it'd use a function f(currenttime,pid)
to seed the random number generator, and any rand() requests
were then treated "normally"
NOW:
At board creation time (or board read time if it has not already happened)
it will use the above algorithm to seed the generator. It will also
keep track of the number of times rand() is called. Later when the
board is read in, it will use the original seed, and make the appropriate
number of calls to rand() as part of the Game::Read() function.
RESULT:
Hopefully, the sequence of rolls will be appear to be more random.
Also, if people want to look into it, we can now make some games
that include a random element "undo"able since the random aspect
is now "repeatable" (given the seed, etc.)
CON:
If you know the seed, and the number of times rand() has been called,
you can "predict" the next roll etc. But since only "trusted" sorts
have access to the games files themselves, I expect this to be of
little consequence.
Thoughts?
Richard
--
/ \__ | Richard Rognlie / Sendmail Ninja / Gamerz.NET Lackey
\__/ \ | http://www.gamerz.net/rrognlie/ <rrognlie@gamerz.net>
/ \__/ | find / -name "*base*" -exec chown us:us {} \;
\__/ | Anything worth doing is worth paying somebody else to do well