From 424c8c80bea4f01b7799f908f181773c705d3a63 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 28 Jul 2022 16:55:29 -0700 Subject: [PATCH] Add debug statements to print xoshiro RNG values This is useful to investigate any TAS desync/reproducibility issues relating to RNG, because even though I specifically separated the Gravitron RNG away from other RNG and made it not dependent on the system libc rand() function, there's still apparently some differences in RNG execution between systems, resulting in TASVideos submission 7575 ( https://tasvideos.org/7575S ) not syncing for everyone except the author. It seems that SDL_GetTicks(), which is used to seed the xoshiro RNG, is not reliably consistent between systems, so in the future I will probably replace it with a counter that is incremented each frame starting from game startup, which is probably better. --- desktop_version/src/Xoshiro.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop_version/src/Xoshiro.c b/desktop_version/src/Xoshiro.c index 29335006..1af6f929 100644 --- a/desktop_version/src/Xoshiro.c +++ b/desktop_version/src/Xoshiro.c @@ -1,5 +1,7 @@ #include +#include "Vlogging.h" + /* Implements the xoshiro128+ PRNG. */ static uint32_t rotl(const uint32_t x, const int k) @@ -44,6 +46,8 @@ uint32_t xoshiro_next(void) s[3] = rotl(s[3], 11); + vlog_debug("Next xoshiro is %u.", result); + return result; } @@ -54,6 +58,8 @@ void xoshiro_seed(uint32_t s) const uint32_t s2 = splitmix32(&s); const uint32_t s3 = splitmix32(&s); seed(s0, s1, s2, s3); + + vlog_debug("Xoshiro seeded with %u.", s); } float xoshiro_rand(void)