summaryrefslogtreecommitdiff
path: root/src/til.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-07-17 17:34:25 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-07-18 01:05:58 -0700
commit209b11f99c801141b79802cd6c23a2b568286f75 (patch)
treeb8d03651c118bdbdcceb3ca1deca4696952d8afe /src/til.c
parentb699465ca96070557feb9e69b898ddb0d4dca2dc (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.c')
-rw-r--r--src/til.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/src/til.c b/src/til.c
index 81a300e..1c2c2fe 100644
--- a/src/til.c
+++ b/src/til.c
@@ -80,14 +80,6 @@ static const til_module_t *modules[] = {
/* initialize rototiller (create rendering threads) */
int til_init(void)
{
- /* Various modules seed srand(), just do it here so they don't need to.
- * At some point in the future this might become undesirable, if reproducible
- * pseudo-randomized output is actually desirable. But that should probably be
- * achieved using rand_r() anyways, since modules can't prevent others from playing
- * with srand().
- */
- srand(time(NULL) + getpid());
-
if (!(til_threads = til_threads_create()))
return -errno;
© All Rights Reserved