summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-23 20:21:07 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-23 20:21:07 -0700
commit49017136713f4cec7ed1dc5b6256988176616e9a (patch)
tree4fc1deedefbe145f423ed7890e3ab5c621db85dc
parenta8d44af30a06f93a95884d67507b6ff2bc74e0a9 (diff)
modules/checkers: add seed to randomized pattern,dynamics
this oversight becomes apparent when stacking checkers as compose layers w/random pattern and/or dynamics. The stacked instances would identical pseudo-random behaviors for lack of seeding.
-rw-r--r--src/modules/checkers/checkers.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c
index 16156a4..cef00f6 100644
--- a/src/modules/checkers/checkers.c
+++ b/src/modules/checkers/checkers.c
@@ -282,7 +282,7 @@ static void checkers_render_fragment(til_module_context_t *context, til_stream_t
break;
}
case CHECKERS_PATTERN_RANDOM:
- state = hash(fragment->number * 0x61C88647) & 0x1;
+ state = hash((context->seed + fragment->number) * 0x61C88647) & 0x1;
break;
}
@@ -304,7 +304,7 @@ static void checkers_render_fragment(til_module_context_t *context, til_stream_t
state ^= ((unsigned)((float)ticks * ctxt->setup->rate) & 0x1);
break;
case CHECKERS_DYNAMICS_RANDOM: /* note: the big multiply here is just to get up out of the low bits */
- state &= hash(fragment->number * 0x61C88647 + (unsigned)((float)ticks * ctxt->setup->rate)) & 0x1;
+ state &= hash((context->seed + fragment->number) * 0x61C88647 + (unsigned)((float)ticks * ctxt->setup->rate)) & 0x1;
break;
}
© All Rights Reserved