Re: Seed in random generation opcodes.

From: Michael J McGonagle (fndsnd@earthlink.net)
Date: Mon Apr 10 2000 - 20:26:11 EDT


> You'll see that sfront is actually "out of spec" at
> the moment in this regard -- if I read this discussion
> correctly, sfront is supposed to use a unique seed
> on each invocation of the sa.c file, so that the
> random numbers are different every time. The idea is,
> if you want "repeatable" random numbers (i.e. under
> the programmers control via a seed) you'll write your
> own from scratch in SAOL.

Maybe this could be a command line option in sfront, as in developing,
it would be nice to always have the same seed. Then once you are
ready...

> sfront/src/lib/csrc/runtime.c
> sfront/src/lib/csrc/runtimef.c
>
> You'll see:
>
> main(int argc, char *argv[])
>
> {
> srand(9753193L);

I changed the above to read the current time and then use that for a
seed. The code is below . Mind you, I have not tested this yet, as when
I went to 'make' the lib, it errored out with "unterminated charater
constant at line 225". Appearently, cygwin does not like a literal
linefeed or carriage return (or whatever it is...). Is there something
that I could change this to to get it to compile?

...replace the above with this...

#include <sys/types.h>
#include <time.h>

main(int argc, char *argv[])

{
  time_t rseedtime;
  (void) time(&rseedtime);

  srand((long) rseedtime); /* use time in seconds to set seed */

...

Hope this works...

Mike



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 11:46:38 EST