diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-07-17 17:34:25 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-07-18 01:05:58 -0700 |
commit | 209b11f99c801141b79802cd6c23a2b568286f75 (patch) | |
tree | b8d03651c118bdbdcceb3ca1deca4696952d8afe /src/til_args.c | |
parent | b699465ca96070557feb9e69b898ddb0d4dca2dc (diff) |
til_args: add --seed= explicit PRNG seeding support
This enables reproducible yet pseudo-randomized visuals, at least
for the fully procedural modules.
The modules that are more simulation-y like sparkler and swarm
will still have runtime variations since they are dependent on
how much the simulation can run and there's been a lot of
sloppiness surrounding delta-t correctness and such.
But still, in a general sense, you'll find more or less similar
results even when doing randomized things like
module=rtv,channels=compose using the same seed value.
For the moment it only accepts a hexadecimal value, the leading
0x is optional.
e.g. these are all valid:
--seed=0xdeadbeef
--seed=0xdEAdBeFf
--seed=0x (produces 0)
--seed=0xff
--seed=deadbeef
--seed=ff
--seed= (produces 0)
--seed=0 (produces 0)
when you exceed the natural word size of an unsigned int on your
host architecture, an overflow error will be returned.
there are remaining issues to be fixed surrounding PRNG
reproducibility, in that things like til_module_randomize_setup()
doesn't currently accept a seed value. However it doesn't even
use rand_r() currently, but when it invokes desc->random() the
module's random() implementation should be able to use rand_r()
and needs to be fed the seed. So that all still needs wiring up
to propagate the root seed down everywhere it may be relevant.
Diffstat (limited to 'src/til_args.c')
-rw-r--r-- | src/til_args.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/til_args.c b/src/til_args.c index e15150f..8969d89 100644 --- a/src/til_args.c +++ b/src/til_args.c @@ -9,7 +9,9 @@ * ./rototiller --video=drm,dev=/dev/dri/card3,connector=VGA-1,mode=640x480@60 * ./rototiller --video=sdl,size=640x480 * ./rototiller --module=roto,foo=bar,module=settings - * ./rototiller --defaults + * ./rototiller --defaults // use default settings where unspecified + * ./rototiller --go // don't show args and wait for user input before proceeding + * ./rototiller --seed=0xdeadbeef // explicitly set global random seed instead of generating one * * unrecognized arguments trigger an -EINVAL error, unless res_{argc,argv} are non-NULL * where a new argv will be allocated and populated with the otherwise invalid arguments @@ -44,6 +46,8 @@ static int args_parse(int argc, const char *argv[], til_args_t *res_args, int *r res_args->video = &argv[i][8]; } else if (!strncasecmp("--module=", argv[i], 9)) { res_args->module = &argv[i][9]; + } else if (!strncasecmp("--seed=", argv[i], 7)) { + res_args->seed = &argv[i][7]; } else if (!strcasecmp("--defaults", argv[i])) { res_args->use_defaults = 1; } else if (!strcasecmp("--help", argv[i])) { @@ -84,6 +88,7 @@ int til_args_help(FILE *out) " --go start rendering immediately upon fulfilling all required settings\n" " --help this help\n" " --module= module settings\n" + " --seed= seed to use for all PRNG in hexadecimal (e.g. 0xdeadbeef)\n" " --video= video settings\n" ); } |