From 49017136713f4cec7ed1dc5b6256988176616e9a Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 23 May 2023 20:21:07 -0700 Subject: 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. --- src/modules/checkers/checkers.c | 4 ++-- 1 file 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; } -- cgit v1.2.3