diff options
| author | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
| commit | 39066900773e7857faf2d02e7ed51b71d219d97d (patch) | |
| tree | ffab8e4ddd971626776c3b1f4ce1da2c186c2187 /src/Godosa.Core/Runs/SeedStreams.cs | |
| download | godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.tar.gz godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.zip | |
godosa-engine: initial public history
Diffstat (limited to 'src/Godosa.Core/Runs/SeedStreams.cs')
| -rw-r--r-- | src/Godosa.Core/Runs/SeedStreams.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Godosa.Core/Runs/SeedStreams.cs b/src/Godosa.Core/Runs/SeedStreams.cs new file mode 100644 index 0000000..385d732 --- /dev/null +++ b/src/Godosa.Core/Runs/SeedStreams.cs @@ -0,0 +1,14 @@ +namespace Godosa.Core.Runs; + +/// <summary>Independent per-purpose seeds from one run seed: SplitMix64 output number <c>stream + 1</c> of +/// <paramref name="seed"/> (audio draws then never shift the game's stream).</summary> +public static class SeedStreams +{ + public static ulong Of(ulong seed, int stream) + { + var z = unchecked(seed + (ulong)(stream + 1) * 0x9E3779B97F4A7C15UL); + z = unchecked((z ^ (z >> 30)) * 0xBF58476D1CE4E5B9UL); + z = unchecked((z ^ (z >> 27)) * 0x94D049BB133111EBUL); + return z ^ (z >> 31); + } +} |
