1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

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.
This commit is contained in:
Misa 2022-07-28 16:55:29 -07:00
parent 058fb9fff0
commit 424c8c80be

View file

@ -1,5 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include "Vlogging.h"
/* Implements the xoshiro128+ PRNG. */ /* Implements the xoshiro128+ PRNG. */
static uint32_t rotl(const uint32_t x, const int k) 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); s[3] = rotl(s[3], 11);
vlog_debug("Next xoshiro is %u.", result);
return result; return result;
} }
@ -54,6 +58,8 @@ void xoshiro_seed(uint32_t s)
const uint32_t s2 = splitmix32(&s); const uint32_t s2 = splitmix32(&s);
const uint32_t s3 = splitmix32(&s); const uint32_t s3 = splitmix32(&s);
seed(s0, s1, s2, s3); seed(s0, s1, s2, s3);
vlog_debug("Xoshiro seeded with %u.", s);
} }
float xoshiro_rand(void) float xoshiro_rand(void)